java's simple method of converting scientific counting to normal counting

  • 2020-05-24 05:37:35
  • OfStack

Today, I found that the data collected in the database was a little too large, and the 1 output was automatically converted to scientific counting. It turned out that there was something wrong with the way the string was converted. As follows:


String a = "11234567.89";

BigDecimal db = new BigDecimal(a);

System.out.println(" Scientific counting: " + db.toString());

System.out.println(" Common count: " + db.toPlainString());

Output:

Scientific count: 1.123456789E7

General count: 11234567.89


Related articles: