开发者

What is the value of binary 100...(31 zeros) for 32-bit integer?

开发者 https://www.devze.com 2023-02-26 15:29 出处:网络
It\'s just a random thought. The two\'s complement of 100...(31 zeros) is also 100... So, the value must be 0. But we know that the binary representation of 0 is 000...

It's just a random thought. The two's complement of 100...(31 zeros) is also 100... So, the value must be 0. But we know that the binary representation of 0 is 000...

I know it can't be a -0 and a +0 b开发者_JAVA百科ecause every binary representation should map to a unique value.


It's −231. Two's complement has only a single zero and the negative range extends one number further than the positive. And yes, that means that there is a single negative number that has no positive equivalent – this is sometimes called the »weird number« since it is an exception of how two's complement numbers are built.


It's the smallest possible value: −231. It's not zero, because 100... is not zero. It's 231.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号