Java Math BigDecimal.toEngineeringString() 方法


Java Math BigDecimal.toEngineeringString() 方法

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;



      bg = new BigDecimal("1E+4");



      // assign the engineering string value of bg to s

      s = bg.toEngineeringString();



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



      // print s value

      System.out.println( str );

   }

}