[docs] (no subject)

Zachary Ware zachary.ware+pydocs at gmail.com
Fri Oct 16 17:26:09 CEST 2015


Hi,

On Wed, Oct 14, 2015 at 1:14 PM, Akanksha Singh
<94singhakanksha at gmail.com> wrote:
> -2**4 gives answer -16 which should be positive ie ans=16.

This is not the correct place to report behavioral bugs; this list is
for discussion of the Python documentation (including bug reports
about the docs).  Better would be either a post to python-list
(python-list at python.org) or a bug report on bugs.python.org.

However, in this case, there is no bug.  You're running into a common
misconception with operator precedence.  `-2**4` is evaluated as
`-(2**4)`, that is, "the negation of 2 to the power of 4."  To get
"the 4th power of negative 2", you'd need to do `(-2)**4`.  See
https://docs.python.org/3/reference/expressions.html#operator-precedence
for more information.

Hope this helps,
-- 
Zach


More information about the docs mailing list