Format BigDecimal without scientific notation with full precision

前端 未结 4 664
感动是毒
感动是毒 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 22:54

    To preserve the precision for a BigDecimal you need to pass the value in as a String

    BigDecimal d = new BigDecimal("12334535345456700.12345634534534578901");
    System.out.println(d.toPlainString());
    

提交回复
热议问题