Power function usage

In the function pow(a,b),can we use

a=pow(32,0.2);
or
a=pow(32,1/5);
a
and expected the results to be returned correctly?
If not why?
No, because 1/5 is division of two integers and thus results in 0. If you then ask the same with 1.0/5, I'll say yes. Though you have to bear in mind that there is some error in floating point operations, because you're trying to represent infinite fractions in finite memory (0.2 is infinite in binary).
Last edited on
1/5 is integer division. You want 1.0/5.0. Other than that, yes.
Topic archived. No new replies allowed.