Why doesn’t pow()
properly handle fractional exponents, and is there a way to force it to? Decimal exponents such as 0.667 are handled correctly, but not fractions such as 2/3. For example, I’d expect
float x = pow(8, 2/3);
to return 4.0 for the value of x
, but it returns 1.0. As another example,
float x = pow(8, 3/2);
returns 8.0. It seems pow()
replaces a fraction with the next lowest integer.