View Single Post
Old 03 July 2022, 10:37   #6
Sim085
Registered User
 
Join Date: Apr 2009
Location: N/A
Posts: 962
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 View Post
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)
Sim085 is offline  
 
Page generated in 0.07891 seconds with 11 queries