I use the pow function in C and store the return value in an integer type. see code snippet below:
for (i = 0; i < 5; i++){ val = (int)pow(5, i); printf("%d, ", val); }
here i , and val are integers, and the result is 1, 5, 24, 124, 624 . I believe this is due to the fact that float 25 is treated as 24.99999 ... which is rounded to 24 when assigned to an integer.
How can I pass this if I still need to store the return value in int?
c pow
Venom Oct 29 '11 at 6:02 2011-10-29 06:02
source share