• <small id='t4WAu'></small><noframes id='t4WAu'>

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

      2. <legend id='t4WAu'><style id='t4WAu'><dir id='t4WAu'><q id='t4WAu'></q></dir></style></legend>
        <tfoot id='t4WAu'></tfoot>

        如何在 Java 中实现无穷大?

        时间:2023-10-01

        1. <small id='otLVw'></small><noframes id='otLVw'>

          <legend id='otLVw'><style id='otLVw'><dir id='otLVw'><q id='otLVw'></q></dir></style></legend>

              <tbody id='otLVw'></tbody>

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

                  <tfoot id='otLVw'></tfoot>

                1. 本文介绍了如何在 Java 中实现无穷大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  Java 是否有任何东西可以表示每种数值数据类型的无穷大?它是如何实现的,以便我可以用它进行数学运算?

                  Does Java have anything to represent infinity for every numerical data type? How is it implemented such that I can do mathematical operations with it?

                  例如

                  int myInf = infinity; //However it is done
                  myInf + 5; //returns infinity
                  myInf*(-1); //returns negative infinity
                  

                  我尝试过使用非常大的数字,但我想要一个合适的简单解决方案.

                  I have tried using very large numbers, but I want a proper, easy solution.

                  推荐答案

                  double 支持 Infinity

                  double supports Infinity

                  double inf = Double.POSITIVE_INFINITY;
                  System.out.println(inf + 5);
                  System.out.println(inf - inf); // same as Double.NaN
                  System.out.println(inf * -1); // same as Double.NEGATIVE_INFINITY
                  

                  打印

                  Infinity
                  NaN
                  -Infinity
                  

                  注意:Infinity - Infinity 不是数字.

                  这篇关于如何在 Java 中实现无穷大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将十六进制字符串解析为整数会引发 NumberFormat 下一篇:如何将 Int 转换为无符号字节并返回

                  相关文章

                  最新文章

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

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

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

                    <legend id='X5xRl'><style id='X5xRl'><dir id='X5xRl'><q id='X5xRl'></q></dir></style></legend>