By sunitram
via martin.ankerl.com
Published: Oct 05 2007 / 06:02
This is a tricky approximation to the a^b calculation. On the tested machine the Java version is 27 times faster than Math.pow(), in C++ it is 7.8 times faster. This is just an approximation, but it might be good enough for many use cases.
Comments
sunitram replied ago:
This is it. I am pretty sure that are the 3 lines of code that took me longest to develop in all the code I have written. It is also the most obscure, and the most amazing code :-)
sunitram replied ago:
Another benchmark: on a Pentium 4, Windows, Java 1.6.0 -server, the approximation is 41 times faster than Math.pow()
Voters For This Link (11)
Voters Against This Link (3)