pow() function question
aeschere
aeschere at nospam.cryptobit.org
Tue Nov 27 09:39:42 PST 2007
Thanks for the help. I am currently using GDC compiler. I am not sure if
I am using phobos or not. I will try to see what std.math.pow gives me.
Michael
Jarrett Billingsley wrote:
> "aeschere" <aeschere at nospam.cryptobit.org> wrote in message
> news:fiheps$2m28$1 at digitalmars.com...
>> I am relatively new to D. So far, I really like it. However, I need to
>> do some power functions on integers. Is pow() the only way of
>> performing this type of function? It seems silly to have to either use
>> reals for integer work. This was one of my gripes with C's pow()
>> function. I check the news archives and noticed there was talk of
>> creating a '**' power function for integers back in 2005. I tried it but
>> it didn't work.
>>
>> Michael
>> (remove nospam if you need to get a hold of me personally)
>
> If you're using phobos, std.math.pow has an overload for integral exponents.
> Although I think it's only highly optimized for lower powers, like up to the
> third or fourth; anything higher and I think it uses floating point numbers.
>
> Keep in mind that floating point performance on modern processors is not
> exactly slow. Doing a power operation (which involves.. what, a ln?
> something like that) might be faster than a loop that multiplies the
> integers over and over.
>
>
More information about the Digitalmars-d-learn
mailing list