Java Math BigInteger.floatValue() 方法


Java Math BigInteger.floatValue() 方法

package com.codingdict;



import java.math.*;



public class BigIntegerDemo {



   public static void main(String[] args) {



      // create 2 BigInteger objects

      BigInteger bi1, bi2;



      // create 2 Float objects

      Float f1, f2;



      // assign values to bi1, bi2

      bi1 = new BigInteger("123");

      bi2 = new BigInteger("-123");



      // assign float values of bi1, bi2 to f1, f2

      f1 = bi1.floatValue();

      f2 = bi2.floatValue();



      String str1 = "Float value of " + bi1 + " is " +f1;

      String str2 = "Float value of " + bi2 + " is " +f2;



      // print f1, f2 values

      System.out.println( str1 );

      System.out.println( str2 );

   }

}