GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Python Technologies
  • Databases
  • Computer Programming
  • Web Development
  • Java Technologies
  • Computer Science
  • Mobile Development
  • Big Data & Analytics
  • Microsoft Technologies
  • DevOps
  • Latest Technologies
  • Machine Learning
  • Digital Marketing
  • Software Quality

This view

  • Original page
  • New address

GeezerVison is showing www.tutorialspoint.com — Java.math.BigInteger.longValue() Method

Java.math package tutorial
  • Java.math - Home
  • Java.math - BigDecimal
  • Java.math - BigInteger
  • Java.math - MathContext
  • Java.math - Enumerations
  • Java.math - Discussion
Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Online Resume Builder
  • HR Interview Questions
  • Computer Glossary
  • Who is Who

Java.math.BigInteger.longValue() Method



Previous
Quiz
Next

Description

The 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.

Declaration

Following is the declaration for java.math.BigInteger.longValue() method.

public long longValue()

Specified by

longValue in class Number.

Parameters

NA

Return Value

This method returns this BigInteger converted to a long.

Exception

NA

Example

The 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
Tutorix - AI Tutor
Previous Quiz Next
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.