Java Math BigDecimal float Value() 方法


Java Math BigDecimal float Value() 方法

package com.codingdict;



import java.math.*;



public class BigDecimalDemo {



   public static void main(String[] args) {



      // create a BigDecimal object

      BigDecimal bg;



      // create a Float object

      Float f;



      bg = new BigDecimal("1234.123486");



      // assign the converted value of bg to f

      f = bg.floatValue();



      String str = "Float value of " + bg + " is " + f;



      // print f value

      System.out.println( str );

   }

}