Why is Int32's maximum value 0x7FFFFFFF?

前端 未结 6 701
野趣味
野趣味 2021-02-02 10:38

I saw in MSDN documents that the maximum value of Int32 is 2,147,483,647, hexadecimal 0x7FFFFFFF.

I think, if it\'s Int32 it should store 32-bi

6条回答
  •  花落未央
    2021-02-02 11:22

    Int32 and Int64 are both signed so they can handle integer values from -capacity/2 to (capacity/2)-1 (for zero) that is why the max value isn't the one you expected. But you can get what you want by using an unsigned int to have only positive numbers.

提交回复
热议问题