pow() works but sqrt() not!?

siggi smusnmrNOSPAM at yahoo.com
Thu Jan 4 08:12:17 EST 2007


Thanks for the explanation. I am astonished what an interpreted language is 
able to do!

"Fredrik Lundh" <fredrik at pythonware.com> schrieb im Newsbeitrag 
news:mailman.2282.1167913096.32031.python-list at python.org...
> "siggi" wrote:
>
>> Nope, I did not! But I used sqrt(9), and not math.sqrt(9). The latter 
>> works
>> excellent, thank you! From now on, I will use "import math" and
>> "math.fuction()" for EVERY mathematical function, even for pow() etc. 
>> just
>> to be on the safe side!
>
> pow and math.pow are two slightly different things, though.  pow() works 
> on
> any type that supports power-of operations (via the __pow__ hook), while
> math.pow treats everything as a 64-bit float:
>
>>>> math.pow(2, 200)
> 1.6069380442589903e+060
>
>>>> pow(2, 200)
> 1606938044258990275541962092341162602522202993782792835301376L
>
> pow also takes a third modulo argument (pow(x,y,z) is equivalent to 
> pow(x,y) % z,
> but can be implemented more efficiently for certain data types).
>
> </F>
>
> 





More information about the Python-list mailing list