• <bdo id='7ByNU'></bdo><ul id='7ByNU'></ul>

    <small id='7ByNU'></small><noframes id='7ByNU'>

        <legend id='7ByNU'><style id='7ByNU'><dir id='7ByNU'><q id='7ByNU'></q></dir></style></legend>

      1. <tfoot id='7ByNU'></tfoot>
      2. <i id='7ByNU'><tr id='7ByNU'><dt id='7ByNU'><q id='7ByNU'><span id='7ByNU'><b id='7ByNU'><form id='7ByNU'><ins id='7ByNU'></ins><ul id='7ByNU'></ul><sub id='7ByNU'></sub></form><legend id='7ByNU'></legend><bdo id='7ByNU'><pre id='7ByNU'><center id='7ByNU'></center></pre></bdo></b><th id='7ByNU'></th></span></q></dt></tr></i><div id='7ByNU'><tfoot id='7ByNU'></tfoot><dl id='7ByNU'><fieldset id='7ByNU'></fieldset></dl></div>
      3. 为什么 Integer.MAX_VALUE + 1 == Integer.MIN_VALUE?

        时间:2023-10-01

      4. <small id='7he6R'></small><noframes id='7he6R'>

        <legend id='7he6R'><style id='7he6R'><dir id='7he6R'><q id='7he6R'></q></dir></style></legend>

      5. <i id='7he6R'><tr id='7he6R'><dt id='7he6R'><q id='7he6R'><span id='7he6R'><b id='7he6R'><form id='7he6R'><ins id='7he6R'></ins><ul id='7he6R'></ul><sub id='7he6R'></sub></form><legend id='7he6R'></legend><bdo id='7he6R'><pre id='7he6R'><center id='7he6R'></center></pre></bdo></b><th id='7he6R'></th></span></q></dt></tr></i><div id='7he6R'><tfoot id='7he6R'></tfoot><dl id='7he6R'><fieldset id='7he6R'></fieldset></dl></div>
          <tbody id='7he6R'></tbody>

          <tfoot id='7he6R'></tfoot>
                  <bdo id='7he6R'></bdo><ul id='7he6R'></ul>
                  本文介绍了为什么 Integer.MAX_VALUE + 1 == Integer.MIN_VALUE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  System.out.println(Integer.MAX_VALUE + 1 == Integer.MIN_VALUE);

                  是真的.

                  我知道 Java 中的整数是 32 位的,不能超过 231-1,但我不明白为什么在其 MAX_VALUE 结果中加 1在 MIN_VALUE 而不是某种异常.更不用说像 Ruby 那样将透明转换为更大的类型.

                  I understand that integer in Java is 32 bit and can't go above 231-1, but I can't understand why adding 1 to its MAX_VALUE results in MIN_VALUE and not in some kind of exception. Not mentioning something like transparent conversion to a bigger type, like Ruby does.

                  此行为是否在某处指定?我可以依赖它吗?

                  Is this behavior specified somewhere? Can I rely on it?

                  推荐答案

                  因为整数溢出.当它溢出时,下一个值是 Integer.MIN_VALUE.相关JLS

                  Because the integer overflows. When it overflows, the next value is Integer.MIN_VALUE. Relevant JLS

                  如果整数加法溢出,则结果是数学和的低位,以某种足够大的二进制补码格式表示.如果发生溢出,则结果的符号与两个操作数值的数学和的符号不同.

                  If an integer addition overflows, then the result is the low-order bits of the mathematical sum as represented in some sufficiently large two's-complement format. If overflow occurs, then the sign of the result is not the same as the sign of the mathematical sum of the two operand values.

                  这篇关于为什么 Integer.MAX_VALUE + 1 == Integer.MIN_VALUE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何通过引用正确传递 Integer 类? 下一篇:09 不被识别,而 9 被识别

                  相关文章

                  最新文章

                • <i id='USPe5'><tr id='USPe5'><dt id='USPe5'><q id='USPe5'><span id='USPe5'><b id='USPe5'><form id='USPe5'><ins id='USPe5'></ins><ul id='USPe5'></ul><sub id='USPe5'></sub></form><legend id='USPe5'></legend><bdo id='USPe5'><pre id='USPe5'><center id='USPe5'></center></pre></bdo></b><th id='USPe5'></th></span></q></dt></tr></i><div id='USPe5'><tfoot id='USPe5'></tfoot><dl id='USPe5'><fieldset id='USPe5'></fieldset></dl></div>
                    • <bdo id='USPe5'></bdo><ul id='USPe5'></ul>

                    1. <legend id='USPe5'><style id='USPe5'><dir id='USPe5'><q id='USPe5'></q></dir></style></legend>

                    2. <small id='USPe5'></small><noframes id='USPe5'>

                      <tfoot id='USPe5'></tfoot>