Why is Int32's maximum value 0x7FFFFFFF?

前端 未结 6 687
野趣味
野趣味 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:23

    In a 2's complement signed n-bit type, the range is from -2n-1 to 2n-1-1 because with n bits you can represent 2n different values, half of which is used for signed numbers because of the sign bit. The remaining 2n-1 half is used for non-negative number. Since one is used for 0, there are only 2n-1-1 remaining values for positive numbers

提交回复
热议问题