为什么int类型的数据可以存储超过9999?

int占4字节,4*8=32位,10进制取值范围为 (-2^31-1)~(2^31-1):-2147483648~2147483647

 1 package test;
 2 
 3 public class test11 {
 4    
 5     public static void main(String[] args) {
 6         int a = 2147483647;
 7         int a1 = 2147483648;//编译报错
 8         int b = -2147483648;
 9         int b1 = -2147483649;//编译报错
10     }
11 }                    

猜你喜欢

转载自www.cnblogs.com/hsqqy/p/10599863.html