pow() works but sqrt() not!?
Fredrik Lundh
fredrik at pythonware.com
Thu Jan 4 13:18:05 CET 2007
"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