- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- Working with BigDecimal values in Java
- Performing Bitwise Operations with BigInteger in Java
- Multiply one BigInteger to another BigInteger in Java
- Subtract one BigInteger from another BigInteger in Java
- Divide one BigInteger from another BigInteger in Java
- Negate a BigInteger in Java
- BigInteger class in Java\n
- Create BigInteger via string in Java
- Math Operations on BigInteger in Java
- Working with csv files in Java
- Shift left in a BigInteger in Java
- Shift right in a BigInteger in Java
- Java Program to get the prime numbers with BigInteger type
- Set a bit for BigInteger in Java
- Create BigInteger from byte array in Java

Advertisements