Message91952
This is not a bug:
-1 ** 2 is parsed as -(1 ** 2), not (-1) ** 2. Take a look at:
http://docs.python.org/reference/expressions.html#the-power-operator
In -1 ^ 2, ^ is the bitwise exclusive-or operator, not the power operator.
pow(x, y) is indeed equivalent to x**y:
Python 2.6.2 (r262:71600, Aug 22 2009, 17:53:25)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = -1
>>> y = 2
>>> x ** y
1
>>> pow(x, y)
1
>>> |
|
Date |
User |
Action |
Args |
2009-08-25 12:35:10 | mark.dickinson | set | recipients:
+ mark.dickinson, benlbroussard |
2009-08-25 12:35:10 | mark.dickinson | set | messageid: <1251203710.03.0.64386610935.issue6781@psf.upfronthosting.co.za> |
2009-08-25 12:35:08 | mark.dickinson | link | issue6781 messages |
2009-08-25 12:35:08 | mark.dickinson | create | |
|