Talk:Exponentiation operator: Difference between revisions

From Rosetta Code
Content added Content deleted
(ints only?)
 
Line 1: Line 1:
== Fractional Exponents ==
This is for integer powers only right? No fractional exponents? --[[User:Mwn3d|Mwn3d]] 05:58, 19 February 2008 (MST)
This is for integer powers only right? No fractional exponents? --[[User:Mwn3d|Mwn3d]] 05:58, 19 February 2008 (MST)

I believe that the REAL * REAL fraction can probably be done faster using some numerical equation. Eg simply
OP ** = ( REAL base, exponent )REAL: exp(log(base)*exponent); ~ # ... #
This above would work for fractional powers. For integral exponents the routine I provided is "sometimes" faster
then alternatives, esp where the exponent is s power of two.

BTW: I wrote these routine as a hint to [[User:Short Circuit]], and as a replacement to the <code>mpz_class pow2(mpz_class exp)</code>
routine he contributed in [[Lucas-Lehmer_test#C++]] (Which is probably painfully slow).

[[User:NevilleDNZ|NevilleDNZ]] 06:11, 19 February 2008 (MST)

Revision as of 13:11, 19 February 2008

Fractional Exponents

This is for integer powers only right? No fractional exponents? --Mwn3d 05:58, 19 February 2008 (MST)

I believe that the REAL * REAL fraction can probably be done faster using some numerical equation. Eg simply

OP ** = ( REAL base, exponent )REAL: exp(log(base)*exponent); ~ # ... #

This above would work for fractional powers. For integral exponents the routine I provided is "sometimes" faster then alternatives, esp where the exponent is s power of two.

BTW: I wrote these routine as a hint to User:Short Circuit, and as a replacement to the mpz_class pow2(mpz_class exp) routine he contributed in Lucas-Lehmer_test#C++ (Which is probably painfully slow).

NevilleDNZ 06:11, 19 February 2008 (MST)