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 -2
Integer.MAX_VALUE
(exclusive) to +2
Integer.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 -2
Integer.MAX_VALUE
(exclusive) to +2
Integer.MAX_VALUE
(exclusive).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…