Java Math BigDecimal.toPlainString() 方法


Java Math BigDecimal.toPlainString() 方法

package com.codingdict;



import java.math.*;



public class BigDecimalDemo {



   public static void main(String[] args) {



      // create a BigDecimal object

      BigDecimal bg;



      // create a String object

      String s;



      MathContext mc = new MathContext(3); // 3 precision



      bg = new BigDecimal("1234E+4",mc);



      // assign the plain string value of bg to s

      s = bg.toPlainString();



      String str = "Plain string value of " + bg + " is " + s;



      // print s value

      System.out.println( str );

   }

}