Format BigDecimal without scientific notation with full precision

前端 未结 4 671
感动是毒
感动是毒 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:20

    The BigDecimal class has a toPlainString method. Call this method instead of the standard toString and it will print out the full number without scientific notation.

    Example

    BigDecimal b = new BigDecimal("4930592405923095023950238502395.3259023950235902");
    System.out.println(b.toPlainString());
    
    Output: 4930592405923095023950238502395.3259023950235902
    

提交回复
热议问题