pow(int , int)
Gokhan Kisacikoglu
kisa@centropolisfx.com
Wed Dec 4 15:54:00 GMT 2002
> so my question is :
>
> pow( ) does not support pow(int, int); ?
>
> just :
>
> long double std::pow(long double, int)
> float std::pow(float, int)
> double std::pow(double, int)
> long double std::pow(long double, long double)
> float std::pow(float, float)
>
Why is this such a big surprize to you? pow is mostly used to compute
the fractional powers (like 1.5, 0.25 etc) and it uses some sort of
Taylor or power series or something internally.
So, if you are trying to compute the integer powers, you are still
better off with the multiplication by itself as much as the power. I
guess you can still optimize that a bit by figuring out first the even
and odd powers etc;
3^15 = c * b * a
a = 3 * 3 = 3^2
b = a * a = 3^4
c = b * b = 3^8
saves you about 10 multiplications (5 instead of 15).
HTH,
Gokhan
More information about the Gcc-help
mailing list