What is the largest integer number base 16 that can be store in a variable of type dword?

耗尽温柔 提交于 2021-01-28 05:48:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!