
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Working with BigInteger Values in Java
The java.math.BigInteger class provides operations analogues to all of Java's primitive integer operators and for all relevant methods from java.lang.Math.
BigInteger class is used for big integer calculations which are outside the limit of the primitive data types. It provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.
The following is an example that displays how we can work with BigInteger values.
Example
import java.math.BigInteger; public class BigIntegerDemo { public static void main(String[] args) { BigInteger bi1, bi2, bi3; // assign values to bi1, bi2 bi1 = new BigInteger("15879"); bi2 = new BigInteger("87687"); bi3 = bi1.add(bi2); String str = "Addition = " +bi3;; System.out.println(str); } }
Output
Addition = 103566
Advertisements