Java Math BigInteger.longValue() 方法


Java Math BigInteger.longValue() 方法

package com.codingdict;



import java.math.*;



public class BigIntegerDemo {



   public static void main(String[] args) {



      // create 2 BigInteger objects

      BigInteger bi1, bi2;



      // create 2 Long objects

      Long l1, l2;



      // assign values to bi1, bi2

      bi1 = new BigInteger("-123");

      bi2 = new BigInteger("9888486986");



      // assign the long values of bi1, bi2 to l1, l2

      l1 = bi1.longValue();

      l2 = bi2.longValue();



      String str1 = "Long value of " +bi1+ " is " +l1;

      String str2 = "Long value of " +bi2+ " is " +l2;



      // print l1, l2 values

      System.out.println( str1 );

      System.out.println( str2 );

   }

}