why Integer.MAX_VALUE + 1 == Integer.MIN_VALUE?

后端 未结 8 1910
鱼传尺愫
鱼传尺愫 2020-11-27 06:57

System.out.println(Integer.MAX_VALUE + 1 == Integer.MIN_VALUE);

is true.

I understand that integer in Java is 32 bit and can\'t go above 23

8条回答
  •  天命终不由人
    2020-11-27 07:38

    The same reason why the date changes when you cross the international date line: there's a discontinuity there. It's built into the nature of binary addition.

提交回复
热议问题