Tomás Ó hÉilidhe wrote:
Very probably the fastest method of calculating powers for that platform.
Not necessarily in all cases.
For example in intel architectures pow() is rather slow because
there's no such FPU opcode in 387. We are probably talking about many
hundreds, if not even over a thousand clock cycles even on a Pentium.
While compilers may try to optimize the pow() call away if they can,
they often can't.
In some cases it may be faster to "open up" a calculation than
calling pow(). For example, in many cases it may be slower to perform a
"pow(x, 1.5)" than a "x*sqrt(x)" (many compilers are unable to optimize
the former into the latter).
But of course this is more related to architectures and compilers than
to C++, and thus slightly off-topic.