Java Math BigInteger.doubleValue() 方法


Java Math BigInteger.doubleValue() 方法

package com.codingdict;



import java.math.*;



public class BigIntegerDemo {



   public static void main(String[] args) {



      // create 2 BigInteger objects

      BigInteger bi1, bi2;



      // create 2 Double objects

      Double d1, d2;



      // assign value to bi1

      bi1 = new BigInteger("123");



      // assign a larger value to bi2

      bi2 = new BigInteger("12345678");



      // assign double value of bi1, bi2 to d1, d2

      d1 = bi1.doubleValue();

      d2 = bi2.doubleValue();



      String str1 = "Double value of " + bi1 + " is " +d1;

      String str2 = "Double value of " + bi2 + " is " +d2;



      // print d1, d2 values

      System.out.println( str1 );

      System.out.println( str2 );

   }

}