In Java, use Math.pow(base, exponent) for quick power calculations — Math.pow(2, 4) returns 16.0.
For everyday math, Math.pow() is the right tool.
A double can only hold about 15–17 significant decimal digits exactly.
When you need exact results of any size, use BigInteger .
Sometimes you want exponentiation without Math.pow — perhaps to stay in integer arithmetic, or as an interview exercise.
Read the complete breakdown, fixes and what happens next.