GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.tutorialspoint.com — Java.math.BigInteger.longValue() Method
Selected Reading
Java.math.BigInteger.longValue() MethodDescriptionThe java.math.BigInteger.longValue() converts this BigInteger to a long. This conversion is analogous to a narrowing primitive conversion from long to int. If this BigInteger is too big to fit in a long, only the low-order 64 bits are returned. This conversion can lose information about the overall magnitude of the BigInteger value as well as return a result with the opposite sign. DeclarationFollowing is the declaration for java.math.BigInteger.longValue() method. public long longValue() Specified bylongValue in class Number. ParametersNA Return ValueThis method returns this BigInteger converted to a long. ExceptionNA ExampleThe following example shows the usage of math.BigInteger.longValue() method. package com.tutorialspoint;
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 );
}
}
Let us compile and run the above program, this will produce the following result − Long value of -123 is -123 Long value of 9888486986 is 9888486986 java_math_biginteger.htm
Advertisements
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |