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

<small id='cGjjn'></small><noframes id='cGjjn'>

      <bdo id='cGjjn'></bdo><ul id='cGjjn'></ul>

      1. <tfoot id='cGjjn'></tfoot>

        为什么整数除以零 1/0 会出错,但浮点数 1/0.0 返回“Inf"?

        时间:2023-05-29
          • <bdo id='4B1tI'></bdo><ul id='4B1tI'></ul>

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

                • <small id='4B1tI'></small><noframes id='4B1tI'>

                  <legend id='4B1tI'><style id='4B1tI'><dir id='4B1tI'><q id='4B1tI'></q></dir></style></legend>

                  本文介绍了为什么整数除以零 1/0 会出错,但浮点数 1/0.0 返回“Inf"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我只是对此感到好奇:

                  在 Java 中计算 1/0 时,会出现以下异常:

                  When evaluating 1/0 in Java, the following exception occurs:

                  线程main"中的异常java.lang.ArithmeticException:/by零在 Foo.main(Foo.java:3)

                  Exception in thread "main" java.lang.ArithmeticException: / by zero at Foo.main(Foo.java:3)

                  但是 1/0.0 被评估为 Infinity.

                  public class Foo {
                      public static void main (String[] args) {
                          System.out.println(1/0.0);
                      }
                  }
                  

                  为什么会这样?

                  推荐答案

                  这是因为整数没有 +/-Inf、NaN 的值,并且不允许除以 0,而浮点数却有这些特殊值.

                  That's because integers don't have values for +/-Inf, NaN, and don't allow division by 0, while floats do have those special values.

                  这篇关于为什么整数除以零 1/0 会出错,但浮点数 1/0.0 返回“Inf"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么 int j = 012 给出输出 10? 下一篇:按从低到高的顺序对整数进行排序 java

                  相关文章

                  <small id='hSF0Z'></small><noframes id='hSF0Z'>

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