The number is held in an int[] - the maximum size of an array is Integer.MAX_VALUE. So the maximum BigInteger probably is (2 ^ 32) ^ Integer.MAX_VALUE.

Admittedly, this is implementation dependent, not part of the specification.


In Java 8, some information was added to the BigInteger javadoc, giving a minimum supported range and the actual limit of the current implementation:

BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.

Implementation note: BigInteger constructors and operations throw ArithmeticException when the result is out of the supported range of -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive).

Answer from assylias on Stack Overflow
Top answer
1 of 3
113

The number is held in an int[] - the maximum size of an array is Integer.MAX_VALUE. So the maximum BigInteger probably is (2 ^ 32) ^ Integer.MAX_VALUE.

Admittedly, this is implementation dependent, not part of the specification.


In Java 8, some information was added to the BigInteger javadoc, giving a minimum supported range and the actual limit of the current implementation:

BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.

Implementation note: BigInteger constructors and operations throw ArithmeticException when the result is out of the supported range of -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive).

2 of 3
23

BigInteger would only be used if you know it will not be a decimal and there is a possibility of the long data type not being large enough. BigInteger has no cap on its max size (as large as the RAM on the computer can hold).

From here.

It is implemented using an int[]:

  110       /**
  111        * The magnitude of this BigInteger, in <i>big-endian</i> order: the
  112        * zeroth element of this array is the most-significant int of the
  113        * magnitude.  The magnitude must be "minimal" in that the most-significant
  114        * int ({@code mag[0]}) must be non-zero.  This is necessary to
  115        * ensure that there is exactly one representation for each BigInteger
  116        * value.  Note that this implies that the BigInteger zero has a
  117        * zero-length mag array.
  118        */
  119       final int[] mag;

From the source

From the Wikipedia article Arbitrary-precision arithmetic:

Several modern programming languages have built-in support for bignums, and others have libraries available for arbitrary-precision integer and floating-point math. Rather than store values as a fixed number of binary bits related to the size of the processor register, these implementations typically use variable-length arrays of digits.

🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigInteger.html
BigInteger (Java Platform SE 8 )
October 20, 2025 - All methods and constructors in this class throw NullPointerException when passed a null object reference for any input parameter. BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.
🌐
GeeksforGeeks
geeksforgeeks.org › java › biginteger-max-and-min-methods-in-java
BigInteger max() and min() Methods in Java - GeeksforGeeks
July 11, 2025 - Java Collection · Last Updated ... method of the BigInteger returns the BigInteger whose value is the greater between current BigInteger and BigInteger passed as a parameter to the method....
🌐
Baeldung
baeldung.com › home › java › java numbers › guide to java biginteger
Guide to Java BigInteger | Baeldung
May 23, 2025 - 1111). To create a number over those limits, we need to use the BigInteger class. Let’s now create a value larger by one than Long.MAX_VALUE, equal to 263.
🌐
Tutorialspoint
tutorialspoint.com › java › math › biginteger_max.htm
BigInteger MAX Value in Java
Following is the declaration for java.math.BigInteger.max() method. public BigInteger max(BigInteger val) val − value with which the maximum is to be computed · This method returns the BigInteger whose value is the greater of this and val. If they are equal, either may be returned.
🌐
Codeforces
codeforces.com › blog › entry › 77623
BigInteger In Java - Codeforces
After reaching that limit they throw garbage values . The maximum value of long can store is Long.MAX_VALUE which is 9223372036854775807 . For working with number larger than this we can you BigInteger in java .
🌐
RoseIndia
roseindia.net › java › java-biginteger › java-biginteger-max-value.shtml
Java BigInteger max value
We can use the max() method of the BigInteger class to get the maximum value of the two BigInteger values.
🌐
Reddit
reddit.com › r/scala › how large can a bigint be?
r/scala on Reddit: How large can a BigInt be?
January 29, 2022 -

Are we limited to something like long long, or unsigned long long, or can a BigInt in theory be as big as I want, given that there is a string-based constructor for that. Can I have a BigInt with 300 or 3000 digits?

The mathematical operations on them as separate methods, do in principle it should be possible to have numbers of arbitrary length and infinite precision, as Mathematica has it.

In Mathematica an integer can have a million digits. That would be hard to scroll, so say 10 thousand or 100 thousand digits. Would that be possible in Scala or Java with BigInt or BigInteger?

🌐
iO Flood
ioflood.com › blog › integer-max-value-java
Java's Integer.MAX_VALUE Explained: A Complete Guide
March 11, 2024 - In this example, we declare a long variable maxLongValue and assign it the value of Long.MAX_VALUE. When we print out maxLongValue, it displays the maximum long value in Java. For even larger numbers, Java provides the BigInteger class.
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › java › java biginteger max value
Max Value From BigInteger in Java | Delft Stack
October 12, 2023 - We create two BigInteger objects, and in the first constructor, we pass a positive value, and in the second constructor, we pass a negative value. When we call the max() method and pass the objects, we get the correct output that is the larger value. import java.math.BigInteger; public class ExampleClass2 { public static void main(String[] args) { BigInteger bigInteger1 = new BigInteger("20003"); BigInteger bigInteger2 = new BigInteger("-20010"); BigInteger getMaxValue = bigInteger1.max(bigInteger2); System.out.println(getMaxValue); } }
🌐
Javatpoint
javatpoint.com › java-biginteger-max-method
Java BigInteger max() method with Examples - Javatpoint
Java BigInteger max() method with Examples on abs(), add(), and(), andNot(), clearBit(), divide(), divideAndRemainder(), flipBit(), gcd(), max(), min(), mod(), modInverse(), modPow(), multiply(), nextProbablePrime(), not(), pow() etc.
🌐
Nullbeans
nullbeans.com › what-is-a-biginteger-and-how-to-use-it-in-java
What is a BigInteger and how to use it in Java – User's blog
One can only assume that this was ... place in the JVM memory is reserved. The officially supported range of values for Big integers is -(2Integer.MAX_VALUE) -1 to +(2Integer.MAX_VALUE) -1 ....
🌐
Oracle
docs.oracle.com › en › java › javase › 23 › docs › api › java.base › java › math › BigInteger.html
BigInteger (Java SE 23 & JDK 23)
October 17, 2024 - All methods and constructors in this class throw NullPointerException when passed a null object reference for any input parameter. BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › math › BigInteger.html
BigInteger (Java SE 11 & JDK 11 )
January 20, 2026 - All methods and constructors in this class throw NullPointerException when passed a null object reference for any input parameter. BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › math › BigInteger.html
BigInteger (Java SE 21 & JDK 21)
January 20, 2026 - All methods and constructors in this class throw NullPointerException when passed a null object reference for any input parameter. BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.
🌐
Educative
educative.io › answers › what-is-the-bigintegermax-method-in-java
What is the BigInteger.max method in Java?
In Java, the BigInteger class handles big integer mathematical operations that are outside the limits of all primitive types. ... The max method takes a BitInteger object as a parameter. If the parameter passed is greater than the current object value, then the parameter is returned.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.biginteger.max
BigInteger.Max(BigInteger) Method (Java.Math) | Microsoft Learn
[<Android.Runtime.Register("max", "(Ljava/math/BigInteger;)Ljava/math/BigInteger;", "GetMax_Ljava_math_BigInteger_Handler")>] abstract member Max : Java.Math.BigInteger -> Java.Math.BigInteger override this.Max : Java.Math.BigInteger -> Java.Math.BigInteger · val · BigInteger · value with which the maximum is to be computed.
🌐
Java Tutorial HQ
javatutorialhq.com › java tutorial › java.math › biginteger › max() method example
Java BigInteger max() method example
September 30, 2019 - The max(BigInteger val) method returns the BigInteger whose value is the greater between this BigInteger and val. If they are equal, either may be returned. ... Below is a java code demonstrates the use of max(BigInteger val) method of BigInteger ...
🌐
Oracle
docs.oracle.com › javase › 9 › docs › api › java › math › BigInteger.html
BigInteger (Java SE 9 & JDK 9 )
All methods and constructors in this class throw NullPointerException when passed a null object reference for any input parameter. BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.