Reply to Jimbob,

"bearophile" <bearophileh...@lycos.com> wrote in message
news:h5h3uf$23s...@digitalmars.com...

Lars T. Kyllingstad:

He also proposed that the overload be called opPower.

I want to add to two small things to that post of mine:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalma
rs.D&article_id=95123

The name opPow() may be good enough instead of opPower().

And A^^3 may be faster than A*A*A when A isn't a simple number, so
always
replacing the
power with mults may be bad.
It wont be on x86. Multiplication has a latency of around 4 cycles
whether int or float, so x*x*x will clock around 12 cycles. The main
instruction needed for pow, F2XM1, costs anywhere from 50 cycles to
120, depending on the cpu. And then you need to do a bunch of other
stuff to make F2XM1 handle different bases.


For constant integer exponents the compiler should be able to choose between the multiplication solution and a intrinsic solution.

also: http://en.wikipedia.org/wiki/Exponentiation#Efficiently_computing_a_power


Reply via email to