What does BigInteger having no limit mean?
The Javadoc for
BigInteger does not define any maximum or minimum. However, it does say:
Immutable arbitrary-precision integers
Is there such a maximum, even in theory? Or is the way
BigInteger operates fundamentally different, such that there is in reality no maximum except for the amount of memory available on the computer?
This question is related to
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:
BigIntegermust support values in the range
Integer.MAX_VALUE(exclusive) and may support values outside of that range.
BigIntegerconstructors and operations throw
ArithmeticExceptionwhen the result is out of the supported range of