I am working on a algorithm to check if number is prime and need to work with really big numbers therefore I am using BigInteger class. Problem is that this exception is thrown ArithmeticException BigInteger would overflow supported range.
Exception in thread "main" java.lang.ArithmeticException: BigInteger would overflow supported range
at java.math.BigInteger.reportOverflow(Unknown Source)
at java.math.BigInteger.checkRange(Unknown Source)
at java.math.BigInteger.<init>(Unknown Source)
at java.math.BigInteger.shiftLeft(Unknown Source)
at java.math.BigInteger.pow(Unknown Source)
at Kitas.main(Kitas.java:118)
And the line where exception is thrown:
b = BigInteger.valueOf(2).pow((int) (35*(Math.pow(2, counter))));
Once counter reaches value of 26, an exception is thrown.