Java_int最大值加一和最小值减一问题

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 17:32   2573   0
public class Temp {
 public static void main(String[] args) {
  int max = Integer.MAX_VALUE;
  int min = Integer.MIN_VALUE;
  System.out.println("int的最大值: " + max); //01111111 11111111 11111111 11111111
  System.out.println("int的最大值+1: " + (max+1));  //11111111 11111111 11111111 11111111
  System.out.println("int的最小值: " + min); //10000000 00000000 00000000 00000000
  System.out.println("int的最小值-1: " + (min-1)); //01111111 11111111 11111111 11111111
 }
}


输出:

int的最大值: 2147483647
int的最大值+1: -2147483648
int的最小值: -2147483648
int的最小值-1: 2147483647

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP