int的小测验题

先看程序

 public static void main(String[] args) throws Throwable {
        int num = 2147483647 ;
        num += 2 ;
        System.out.println(num) ;
    }

java中int的取值范围为-2147483648到+2147483648。当结果超出int的范围后,将采用补码的形式表示。原码转换为补码的规则:符号位不变,数值位按位取反,末位再加1。

所以运行的结果大家自己卡伊跑下程序看看

posted @ 2020-07-17 20:36  沉默小和尚  阅读(191)  评论(0编辑  收藏  举报