I'm using the math library in combination with the JexlEngine to calculate different equations. In this equations I also have the
You can compare the exponent to
double base = 99999; double maxExp = Math.log(Long.MAX_VALUE)/Math.log(base);
if the power is above maxExp, you will get an overflow.