[英]Binary Representation of Integer.MIN_VALUE
The binary representation of Integer.MIN_VALUE
in Java is 10000000000000000000000000000000
. Java中Integer.MIN_VALUE
的二进制表示形式是10000000000000000000000000000000
。
Why wouldn't it be 10000000000000000000000000000001
instead, since the addition of one to its two's complement would be larger than 10000000000000000000000000000000
by one? 为什么不改为10000000000000000000000000000001
,因为在其补码数中加一会比10000000000000000000000000000000
?
int
in Java is a signed 32-bit number, meaning that the 32th bit, like you said, represents the negative number, in decimal, -(2^31)
, and in binary: Java中的int
是一个带符号的32位数字,这意味着第32位(如您所说)代表负数,以十进制-(2^31)
和二进制形式表示:
10000000000000000000000000000000
^ → "negative bit"
But the remaining 31 bits are still "positive" bits in a signed system, so: 但是在签名系统中,其余31位仍然是“正”位,因此:
10000000000000000000000000000001 → -2^31 + 1
And -2^31 + 1
is bigger than -2^31
. 并且-2^31 + 1
大于-2^31
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.