Raymond Hettinger added the comment:
Python's order of operations runs the exponentation before the unary minus.
This convention makes the unary minus behave more like the subtraction operator
so that: -x**n == 0 - x**n.
This convention is somewhat common but there are exceptions such as MS
Senthil Kumaran added the comment:
It's to do with operator precedence.
** takes higher precedence than negative.
http://docs.python.org/reference/expressions.html#Summary
(-5) ** 4 will give what you are looking for.
--
nosy: +orsenthil
resolution: -> invalid
stage: -> committed/r
New submission from eswar s :
-5 ** 4 results as -625. It should be 625
--
components: None
messages: 118311
nosy: eswar.s
priority: normal
severity: normal
status: open
title: ** operator yielding wrong result for negative numbers
type: compile error
versions: Python 2.6
__