[New-bugs-announce] [issue41485] Repr of complex number with signed zero does not roundtrip

Eric Wieser report at bugs.python.org
Wed Aug 5 05:05:28 EDT 2020


New submission from Eric Wieser <wieser.eric at gmail.com>:

Python distinguishes signed zeros by their repr:

# floats
>>> 0.0
0.0
>>> -0.0
-0.0

# complex
>>> complex(0.0, 0.0)  # A
0j
>>> complex(0.0, -0.0)  # B
-0j
>>> complex(-0.0, 0.0)  # C
(-0+0j)
>>> complex(-0.0, -0.0)  # D
(-0+0j)

However, only one of these `complex` reprs round-trips:

>>> 0j   # ok
0j
>>> -0j   # doesn't round-trip
(-0-0j)
>>> (-0+0j)  # doesn't round-trip
0j
>>> (-0-0j)
0j

----------
components: Interpreter Core
messages: 374864
nosy: Eric Wieser
priority: normal
severity: normal
status: open
title: Repr of complex number with signed zero does not roundtrip
versions: Python 3.8

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


More information about the New-bugs-announce mailing list