Java Math BigDecimal.valueOf(double val) 方法


Java Math BigDecimal.valueOf(double val) 方法

package com.codingdict;



import java.math.*;



public class BigDecimalDemo {



   public static void main(String[] args) {



      // create a BigDecimal object

      BigDecimal bg;



      // create a Double Object

      Double d = new Double("123.45678");



      // assign the bigdecimal value of d to bg

      // static method is called using class name

      bg = BigDecimal.valueOf(d);



      String str = "The Double After Conversion to BigDecimal is " + bg;



      // print bg value

      System.out.println( str );

   }

}