Maddoga Maddoga - 4 days ago 8
Java Question

Working beyond Max Value (Java)

I have a problem that requires me to go well beyond the Max Value of Integers in Java. How can I have an exception so that Java will let me do this, or get around these rules of Java?

Answer

Use a long value or Long wrapper.

When you've reached Long.MAX_VALUE then use BigInteger, which has a very large capacity, at least from -2^Integer.MAX_VALUE to 2^Integer.MAX_VALUE.

Come back for additional tips when BigInteger is no longer enough.

Comments