int数据类型的最大值的加上1变成负的最小值的问题的解释...


关于int数据类型的数的最大值加上一之后变成负的最小值的问题的解释!!
  1. public class Test {  
  2.     public static void main(String[] args) {  
  3.         int max = Integer.MAX_VALUE;  
  4.         int min = Integer.MIN_VALUE;  
  5.         System.out.println("int的最大值: " + max);  //01111111 11111111 11111111 11111111  
  6.         System.out.println("int的最大值+1: " + (max+1));        //11111111 11111111 11111111 11111111  
  7.         System.out.println("int的最小值: " + min);  //10000000 00000000 00000000 00000000  
  8.         System.out.println("int的最小值-1: " + (min-1));    //01111111 11111111 11111111 11111111  
  9.     }  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM