OK, I know that there was many question about pow function and casting it\'s result to int, but I couldn\'t find answer to this a bit specific question.
OK, this is
I'm fairly sure this can be explained by "intermediate rounding" and the fact that pow
is not simply looping around j
times multiplying by i
, but calculating using exp(log(i)*j)
as a floating point calculation. Intermediate rounding may well convert 24.999999999996 into 25.000000000 - even arbitrary storing and reloading of the value may cause differences in this sort of behaviuor, so depending on how the code is generated, it may make a difference to the exact result.
And of course, in some cases, the compiler may even "know" what pow
actually achieves, and replace the calculation with a constant result.