Home Java Java-biginteger Java BigInteger example
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java BigInteger example

Advertisement
BigInteger class provides us operations for modular arithmetic (such as add, subtract) , prime generation , bit manipulation and many other useful operations.

Java BigInteger example

     

BigInteger class provides us operations for modular arithmetic (such as add, subtract) , prime generation , bit manipulation and many other useful operations.

Here in this example of BigInteger we have created two big integer variables and we are going to multiply them and will store that result in another BigInteger variable. Here is the full example code of BigIntegerExample.java as follows:

 

 

 

BigIntegerExample.java

import java.math.BigInteger;
public class BigIntegerExample 
{
  public static void main(String[] args
  {
  BigInteger bigInteger1 = new BigInteger ("123456789");
  BigInteger bigInteger2 = new BigInteger ("112334");
  BigInteger bigIntResult =
    bigInteger1.multiply
(bigInteger2)
  System.out.println("Result is  ==> " + bigIntResult);
  }
}

Output of the above program is as follows:

C:\biginteger>javac BigIntegerExample.java

C:\biginteger>java BigIntegerExample
Result is ==> 13868394935526

Download Source Code

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 4, 2008

Ask Questions?    Discuss: Java BigInteger example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com