[issue25839] negative zero components are ignored in complex number literals

2015-12-11 Thread Mark Dickinson
Mark Dickinson added the comment: Previous discussions: #17336, #22548 -- ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue25839] negative zero components are ignored in complex number literals

2015-12-11 Thread Mark Dickinson
Mark Dickinson added the comment: > As I understand the output of repr() is supposed to be something that can > evaluated to recreate the same object. Right, but that's an ideal that's not always achieved in practice. If I had my druthers, I'd 'fix' the repr of the complex object to return som

[issue25839] negative zero components are ignored in complex number literals

2015-12-11 Thread Mark Dickinson
Mark Dickinson added the comment: This is something that comes up repeatedly on the bug tracker. There's no bug here in the complex type or the repr. What there *is* is a limitation resulting from the fact that Python doesn't have *imaginary* literals, only *complex* literals. So in: -1-0j t

[issue25839] negative zero components are ignored in complex number literals

2015-12-11 Thread Mark Lundeberg
Mark Lundeberg added the comment: Good point, it is doing (int-complex), observe also the following pecularities: >>> -0 - 0j 0j >>> -0. - 0j (-0+0j) >>> -0j -0j >>> 0-0j 0j >>> -(0j) (-0-0j) >>> 0.+(-0j) 0j Does this mean the bug is in repr() ? As I understand the output of repr() is supposed

[issue25839] negative zero components are ignored in complex number literals

2015-12-11 Thread STINNER Victor
STINNER Victor added the comment: You should use complex(a, b) to have a reliable behaviour. Python parse doesn't see "-1-0j" as a complex literal, but as (-1)-(0j): int-complex. Example with the AST output: >>> ast.dump(ast.parse('-1-0j')) 'Module(body=[Expr(value=BinOp(left=UnaryOp(op=USub()

[issue25839] negative zero components are ignored in complex number literals

2015-12-11 Thread Mark Lundeberg
New submission from Mark Lundeberg: Although -0.0 and +0.0 compare as equal using the == operator, they are distinct floating point numbers and in some cases behave differently. (See more information on the wikipedia article "Signed zero".) The distinction between +0.0 and -0.0 is most importa