久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

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

      1. 防止 Java 中 String.format("%.2f", doubleValue) 的

        Prevent round off in String.format(quot;%.2fquot;, doubleValue) in Java(防止 Java 中 String.format(%.2f, doubleValue) 的舍入)

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

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

                  <bdo id='DFbuU'></bdo><ul id='DFbuU'></ul>
                • 本文介紹了防止 Java 中 String.format("%.2f", doubleValue) 的舍入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如何防止 String.format("%.2f", doubleValue); 舍入(四舍五入算法)而不是截斷它?

                  How do I prevent String.format("%.2f", doubleValue); from rounding off (round half up algorithm) instead of just truncating it?

                  例如

                  doubleValue = 123.459
                  

                  格式化后,

                  doubleValue = 123.46
                  

                  我只想丟棄最后一位,

                  123.45
                  

                  我知道還有其他方法可以做到這一點,我只想知道這是否可以使用 String.format.

                  I know there are other ways to do this, I just want to know if this is possible using the String.format.

                  推薦答案

                  你可以隨時設置舍入模式:

                  You can always set the rounding mode:

                  http://java.sun.com/javase/6/docs/api/java/math/RoundingMode.html

                  然后使用 String.Format()默認使用 HALF_EVEN,但您可以將其更改為 CEILING

                  and then use String.Format() HALF_EVEN is used by default, but you can change it to CEILING

                  另一種不太靈活的方法是(但這不是你問的):

                  another no so flexible approach will be (but this is not what you asked about):

                  DecimalFormat df = new DecimalFormat("###.##");
                  df.format(123.459);
                  

                  這篇關于防止 Java 中 String.format("%.2f", doubleValue) 的舍入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                • <small id='pSfBO'></small><noframes id='pSfBO'>

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

                          • 主站蜘蛛池模板: av片免费 | 日韩一区二区三区视频 | 欧美啪啪网站 | 国产精品色综合 | 男人天堂av网站 | 国产日韩欧美 | 精品视频在线一区 | 日韩在线视频精品 | 亚洲视频中文字幕 | 在线看片网站 | 久久久久久久久久性 | 亚洲一区 | 丝袜毛片| 国产特黄一级 | 国产精品色哟哟网站 | 懂色av色香蕉一区二区蜜桃 | 亚洲一区二区三区视频 | 国产精品久久国产精品久久 | caoporon| 久久精品一区二区三区四区 | 特级做a爰片毛片免费看108 | 久久国产婷婷国产香蕉 | 国产精品美女久久久久久免费 | 国产精品日本一区二区在线播放 | 国产精品久久性 | 国产精品区一区二 | 最新中文字幕在线 | 亚洲一区二区中文字幕 | 狠狠操天天操 | 久久久久亚洲精品 | 国产区在线 | 国产欧美一区二区三区久久 | 日本免费黄色 | 国产精品久久久久久久毛片 | 一区二区福利视频 | 欧美亚洲视频 | 97精品超碰一区二区三区 | 91国产精品在线 | 99这里只有精品视频 | 91精品在线观看入口 | 亚洲视频在线观看免费 |