I changed the code to float but still get same result:
Code:
float base, power, result;
base = 2; power = 2;
result = pow(base,power);
printf("a: %.2f b: %.2f\n", result, pow(base,power));
But this still gives the following result:
Code:
a: 1074790400.00 b: 4.00
When I check pow definition on the internet it takes two double parameters and returns a double which is why I was using double.
Quote:
Originally Posted by jotd
what is this output?
Check how pow is defined in your case. Is it returning a "float" or a "double"? if it returns a float, it's not going to end well with printf as %lf format is double (assigning in a double before hand solves the issue)
|