美文网首页
内存溢出

内存溢出

作者: 望舒_ | 来源:发表于2023-10-15 09:32 被阅读0次
    Integer型溢出gpt解释.png
    /**
     * https://www.nowcoder.com/exam/test/75038824/submission?examPageSource=Intelligent&pid=53682268&testCallback=https%3A%2F%2Fwww.nowcoder.com%2Fexam%2Fintelligent%3FquestionJobId%3D10
     * 涉及到微机原理中的补码---负数的补码是在原码的基础上,符号位不变(仍为1),数值位按位取反,末位加1。
     * 因为byte是有符号单字节整形,所以存储数字范围是[-128·127]而127[01111111]+1==128[10000000]。为什么呢?因为科学家定义数字的时候是一个环,最大的数字后面就是最小,这样才可以把[0·255]分配给[-128·127]
      */
    public class HelloWorld {
        public static void main(String[] args) {
            byte b = (byte) 129;
            byte c = (byte) 128;
            System.out.println(b);
            System.out.println(c);
        }
    }
    

    相关文章

      网友评论

          本文标题:内存溢出

          本文链接:https://www.haomeiwen.com/subject/dzrtidtx.html