math.pow(x,y)

Gary Herron gherron at islandtraining.com
Sun Jun 11 15:20:42 EDT 2006


Wojciech Muła wrote:
> fl1p-fl0p wrote:
>   
>> import math
>> math.pow(34564323, 456356)
>>
>> will give math range error.
>>
>> how can i force python to process huge integers without math range
>> error? Any modules i can use possibly?
>>     
>
> You have to use operator **, i.e. 34564323**456356
>   
That's not very practical. That computation will produce a value with
more than 3.4 million digits. (That is, log10(34564323)*456356 =
3440298.) Python will attempt this, but I was not patient enough to see
if it could calculate an answer today (or even this week).

I doubt that you really *want* all 3.4 million digits. So what is it you
really want? A scientific or engineering result as a floating point
number accurate to some reasonable number of digits? That integer value
modulo some other integer (as used in various cryptology schemes)?

Gary Herron




More information about the Python-list mailing list