Geek Geek - 1 year ago 120
Java Question

What does BigInteger having no limit mean?

I looked into this stackoverflow question relating to Big Integer and specifically I do not understand this line (the words in italics):

In the BigInteger class, I have no limits and there are some helpful
functions there but it is pretty depressing to convert your beautiful
code to work with the BigInteger class, specially when primitive
operators don't work there and you must use functions from this class.

I don't know what I am missing but to represent something that has no limit you would require infinite memory ? Whats is the trick here ?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download