Here's a C code;
#include<stdio.h>
#include<math.h>
int main()
{
double n=10.0;
double automatic = pow(10.0,log10(n)-log10(5.0));
printf("%.9lf\n",log10(n)-log10(5.0));
printf("%.9lf\n",pow(10.0,0.30102996));
double manual = pow(10.0,0.30102996);
printf("%.9lf %lf\n",automatic, floor(automatic));
printf("%.9lf %lf\n",manual,floor(manual));
return 0;
}
Output is:
0.301029996
1.999999836
2.000000000 1.000000
1.999999836 1.000000
From output I can infer that in pow(x,y) y is rounded off to 6 digits because it's signature is as pow(double x, double y) so that 0.301029996 becomes 0.301030 and that's why value of automatic is 2.000000000 otherwise it would be same as manual.
My questions:
- Is my inferation correct?
- If answer to first question is true then how can we bypass this rounding-off to achieve more accurate results?