What does BigInteger having no limit mean?
Graham gave great answer to this question. I would like only to add that you have to be carefull with valueOf
method because it is created using long
parameter so the maximum value is Long.MAX_VALUE
.
Yes its used when we need very big numbers with arbitrary precision. It's important to note that "arbitrary" precision or number of digits does not mean "unlimited": it means that the number of digits in a number or number of digits of precision in a calculation is limited by memory and/or defined limits to precision that we specify.
There is no theoretical limit. The BigInteger
class allocates as much memory as it needs for all the bits of data it is asked to hold.
There are, however, some practical limits, dictated by the memory available. And there are further technical limits, although you're very unlikely to be affected: some methods assume that the bits are addressable by int
indexes, so things will start to break when you go above Integer.MAX_VALUE
bits.