Format BigDecimal without scientific notation with full precision

前端 未结 4 667
感动是毒
感动是毒 2021-02-06 22:26

I\'d like to convert a BigDecimal to String for printing purposes but print out all digits without scientific notation. For example:

Bi         


        
4条回答
  •  被撕碎了的回忆
    2021-02-06 23:04

    You want to use a DecimalFormat:

    DecimalFormat df = new DecimalFormat("#.#");  
    String output = df .format(myBD);
    System.out.println(value + " " + output);
    

提交回复
热议问题