[New-bugs-announce] [issue42428] Inconsistent squaring behavior

JohnSmith11132 report at bugs.python.org
Sat Nov 21 14:56:52 EST 2020


New submission from JohnSmith11132 <wbx96811 at cuoly.com>:

Basically when squaring as a negative number, if it's a variable it acts like -3*-3 otherwise it acts like 3*-3.
For example:
>>> x = -3
>>> x ** 2
9
>>> -3 ** 2
-9

pow(-3, 2) seems to act like -3 * -3?
** 3 seems fine and both seems to act like -3*-3*-3.
>>> x = -3
>>> x ** 3
27
>>> -3 ** 3
-27

Will it be safe to use the ** 2 in Python? If I use a variable will it return the same value?

I only found this for the bug:
https://devforum.roblox.com/t/inconsistent-squaring-behavior/820028/

It looks like the exact same issue I'm having, but I still don't get it and it's not for Python.

----------
components: Interpreter Core
messages: 381573
nosy: JohnSmith11132
priority: normal
severity: normal
status: open
title: Inconsistent squaring behavior
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42428>
_______________________________________


More information about the New-bugs-announce mailing list