<legend id='VYPYB'><style id='VYPYB'><dir id='VYPYB'><q id='VYPYB'></q></dir></style></legend>
        <bdo id='VYPYB'></bdo><ul id='VYPYB'></ul>

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

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

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

        如何获得小数点后的数字?(爪哇)

        How to get the numbers after the decimal point? (java)(如何获得小数点后的数字?(爪哇))
      1. <legend id='YSVZ8'><style id='YSVZ8'><dir id='YSVZ8'><q id='YSVZ8'></q></dir></style></legend>
        • <small id='YSVZ8'></small><noframes id='YSVZ8'>

            • <bdo id='YSVZ8'></bdo><ul id='YSVZ8'></ul>
                <tbody id='YSVZ8'></tbody>

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

                  本文介绍了如何获得小数点后的数字?(爪哇)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                   double d = 4.321562;
                  

                  有没有一种简单的方法可以从 d 中自行提取 0.321562?我试着在数学课上找,但没有运气.如果这可以在不转换为字符串或强制转换为其他任何内容的情况下完成,那就更好了.

                  Is there an easy way to extract the 0.321562 on it's own from d? I tried looking in the math class but no luck. If this can be done without converting to string or casting to anything else, even better.

                  推荐答案

                  嗯,你可以使用:

                  double x = d - Math.floor(d);
                  

                  请注意,由于二进制浮点的工作方式,它不会准确地为您提供 0.321562,因为原始值不是准确地 4.321562.如果你真的对精确数字感兴趣,你应该改用 BigDecimal.

                  Note that due to the way that binary floating point works, that won't give you exactly 0.321562, as the original value isn't exactly 4.321562. If you're really interested in exact digits, you should use BigDecimal instead.

                  这篇关于如何获得小数点后的数字?(爪哇)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

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

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

                      <legend id='pV3YL'><style id='pV3YL'><dir id='pV3YL'><q id='pV3YL'></q></dir></style></legend>
                        <tbody id='pV3YL'></tbody>
                        <tfoot id='pV3YL'></tfoot>

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