问题
What's the largest number it can store?
More importantly, could someone explain why dword can't store a larger number?
回答1:
It has nothing to do with the base used per se. The largest number a DWORD can store is constrained by the fact that DWORD (at least in typical usage of DWORD, which is a Microsoft typedef) is a 32 bit wide unsigned integer. That means the largest number it can store is 2^32-1.
- In binary that's
11111111111111111111111111111111
. - In hex it's
0xFFFFFFFF,
as @GregHewgill said. - In Decimal that's
4294967295
. - In octal that's
37777777777
.
Those are the same number just using different bases. Binary shows what's truly going on at a machine level. Maximum value of DWORD, which is 32 bits wide, has all 32 bits on.
回答2:
Assume that your dword
is 32 bits. The largest number that can be stored in 32 bits in binary is all 1s:
11111111111111111111111111111111
In base 16 (hex), this is
0xFFFFFFFF
You can't store an integer any larger than this because then you would need 33 bits.
来源:https://stackoverflow.com/questions/14047722/what-is-the-largest-integer-number-base-16-that-can-be-store-in-a-variable-of-ty