Java中Double原樣輸出,取消科學計數法


import java.text.NumberFormat;

public class test {
    
    public static void main(String[] args) {
         double d =12345.00000000225168d;
         String s=formatDouble(d);
         System.out.println(s);
    }
     private static String formatDouble(double d) {
            NumberFormat nf = NumberFormat.getInstance();
            //設置保留多少位小數
            nf.setMaximumFractionDigits(20);
             // 取消科學計數法
            nf.setGroupingUsed(false);
            //返回結果
            return nf.format(d);
        }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM