I have a problem with this program where I have to calculate the value of base^expo, and the base is a real number whereas the exponent is an integer. With (95.123)^12
I'm expecting 548815620517731830194541.899025343415715973535967221869852721
, but my program produces 548815620517732160000000.000000
, which is wrong. Please suggest a better approach.
// declare variables and read values
double myBase = scan.nextDouble();
int myExponent = scan.nextInt();
// display result
System.out.printf("%f", Math.pow(myBase, myExponent));