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.

🌐
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.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigInteger.html
BigInteger (Java Platform SE 8 )
October 20, 2025 - the BigInteger whose value is the greater of this and val. If they are equal, either may be returned. ... Returns the hash code for this BigInteger. ... Returns the String representation of this BigInteger in the given radix. If the radix is outside the range from Character.MIN_RADIX to Character.MAX_RADIX inclusive, it will default to 10 (as is the case for Integer...
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › java › biginteger-max-and-min-methods-in-java
BigInteger max() and min() Methods in Java - GeeksforGeeks
July 11, 2025 - /* *Program Demonstrate max() method of BigInteger */ import java.math.*; public class GFG { public static void main(String[] args) { // Create 2 BigInteger objects BigInteger biginteger=new BigInteger("8976543245"); BigInteger val=new BigInteger("9248040402"); // Call max() method to find greater value // between two BigIntegers. BigInteger biggerInteger = biginteger.max(val); String result = "Bigger Integer between "+biginteger+" and " +val+ " is " +biggerInteger; // Prints the result System.out.println(result); } } Output: Bigger Integer between 8976543245 and 9248040402 is 9248040402 ·
🌐
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 .
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-max_value-and-integer-min_value-in-java-with-examples
Integer.MAX_VALUE and Integer.MIN_VALUE in Java with Examples - GeeksforGeeks
July 12, 2025 - Example 2: Trying to initialize ... + " Integer.MAX_VALUE + 1"); // Try to store value Integer.MAX_VALUE + 1 int N = Integer.MAX_VALUE + 1; // Print the value of N System.out.println("N = " + N); } catch (Exception e) { ...
🌐
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.
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › java numbers › guide to java biginteger
Guide to Java BigInteger | Baeldung
May 23, 2025 - ... As we already know, the long data type is a 64-bit two’s complement integer. The signed long has a minimum value of -263 (1000 0000 … 0000) and a maximum value of 263-1 (0111 1111
🌐
CodeGym
codegym.cc › java blog › java numbers › integer max_value in java with examples
Integer MAX_VALUE in Java with Examples
December 10, 2024 - Integer.MAX_VALUE is a number in the Java Integer сlass of java.lang package. It is the maximum possible Integer number that can be represented in 32 bits. Its exact value is 2147483647 i.e.
Top answer
1 of 11
450

In C, the language itself does not determine the representation of certain datatypes. It can vary from machine to machine, on embedded systems the int can be 16 bit wide, though usually it is 32 bit.

The only requirement is that short int <= int <= long int by size. Also, there is a recommendation that int should represent the native capacity of the processor.

All types are signed. The unsigned modifier allows you to use the highest bit as part of the value (otherwise it is reserved for the sign bit).

Here's a short table of the possible values for the possible data types:

          width                     minimum                         maximum
signed    8 bit                        -128                            +127
signed   16 bit                     -32 768                         +32 767
signed   32 bit              -2 147 483 648                  +2 147 483 647
signed   64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807
unsigned  8 bit                           0                            +255
unsigned 16 bit                           0                         +65 535
unsigned 32 bit                           0                  +4 294 967 295
unsigned 64 bit                           0     +18 446 744 073 709 551 615

In Java, the Java Language Specification determines the representation of the data types.

The order is: byte 8 bits, short 16 bits, int 32 bits, long 64 bits. All of these types are signed, there are no unsigned versions. However, bit manipulations treat the numbers as they were unsigned (that is, handling all bits correctly).

The character data type char is 16 bits wide, unsigned, and holds characters using UTF-16 encoding (however, it is possible to assign a char an arbitrary unsigned 16 bit integer that represents an invalid character codepoint)

          width                     minimum                         maximum

SIGNED
byte:     8 bit                        -128                            +127
short:   16 bit                     -32 768                         +32 767
int:     32 bit              -2 147 483 648                  +2 147 483 647
long:    64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807

UNSIGNED
char     16 bit                           0                         +65 535
2 of 11
84

In C, the integer(for 32 bit machine) is 32 bit and it ranges from -32768 to +32767.

Wrong. 32-bit signed integer in 2's complement representation has the range -231 to 231-1 which is equal to -2,147,483,648 to 2,147,483,647.

🌐
GeeksforGeeks
geeksforgeeks.org › java › biginteger-class-in-java
BigInteger Class in Java - GeeksforGeeks
There is no theoretical limit on the upper bound of the range because memory is allocated dynamically but practically as memory is limited you can store a number that has Integer.MAX_VALUE number of bits in it which should be sufficient to store ...
Published   July 23, 2025
🌐
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?

🌐
Quora
quora.com › How-do-I-set-a-big-integer-value-in-Java
How to set a big integer value in Java - Quora
Answer (1 of 2): A big integer is not a [code ]BigInteger[/code]! A big integer can be set simply using the assignment operator: [code]int bigEnoughNumber = Integer.MAX_VALUE; [/code]Otherwise [code ]java.math.BigInteger[/code] instances are immutable! Once the instance is initialized with a val...
🌐
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 - The range of probable prime values is limited and may be less than the full supported positive range of BigInteger. The range must be at least 1 to 2500000000. ... As BigInteger values are arbitrary precision integers, the algorithmic complexity of the methods of this class varies and may be ...
🌐
W3Docs
w3docs.com › java
max value of integer
In Java, the maximum value of an int type is 2147483647. This is the highest positive number that can be represented with a 32-bit binary number. You can use the Integer.MAX_VALUE constant to get the maximum value of an int in your Java program:
🌐
Baeldung
baeldung.com › home › core concepts › programming › maximum value of an integer: java vs c vs python
Maximum Value of an Integer: Java vs C vs Python | Baeldung on Computer Science
March 18, 2024 - But with Java, we can go further with a little hack so we can represent very large integer numbers through the BigInteger class library. This library combines arrays of smaller variables to build up huge numbers.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java integer and java biginteger class with examples
Java Integer And Java BigInteger Class With Examples
April 1, 2025 - As we know that the Java integer type ‘int’ has a range from –2,147,483,648 to 2,147,483,647 which is also from -231 to 231-1. We can also derive these values by using Java max int.