[issue40269] Inconsistent complex behavior with (-1j)

2020-08-05 Thread Mark Dickinson
Mark Dickinson added the comment: Updating resolution to "duplicate", in an effort to keep discussion in a single place. -- resolution: not a bug -> duplicate superseder: -> Complex number representation round-trip doesn't work with signed zero values

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: After reading through the comments, I don't think we should change repr(complex) unless there is computational issue, such as eval(repr(z) != z. Raymond, I agree with your overlooked doc tweek. If you submit a PR, you can ask me to review. --

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-28 Thread Mark Dickinson
Mark Dickinson added the comment: Closing this. Please open a separate issue for changing the complex repr if that's the way that you want to go. -- resolution: -> not a bug stage: patch review -> resolved status: open -> closed ___ Python

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-19 Thread Mark Dickinson
Mark Dickinson added the comment: > I tried to make repr of floats producing a string which rounds up with eval() We've looked at this before. There just isn't any sane and easy way to do this, except for changing the repr to be "complex(real, imag)", which is the solution that I favour.

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I tried to make repr of floats producing a string which rounds up with eval() (see PR 19593). >>> complex(0.0, 1.0) 1j >>> complex(0.0, -1.0) (0-1j) >>> complex(-0.0, 1.0) -(0-1j) >>> complex(-0.0, -1.0) (-0.0-1j) >>> complex(1.0, 0.0) (1+0j) >>>

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-19 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +18928 pull_request: https://github.com/python/cpython/pull/19593 ___ Python tracker ___

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: Since integers don't have signed zeros, the use of integers in the complex repr is a little weird: >>> (-0-1j) # The unary minus in the repr has no effect. -1j >>> (0-1j) -1j -- ___ Python tracker

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-13 Thread Mark Dickinson
Mark Dickinson added the comment: Another related issue is #23229, where Guido says (in msg233963): > BTW I don't want repr() of a complex number to use the > complex(..., ...) notation -- it's too verbose. -- ___ Python tracker

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-13 Thread Mark Dickinson
Change by Mark Dickinson : -- keywords: +patch pull_requests: +18849 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19498 ___ Python tracker ___

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-13 Thread Mark Dickinson
Mark Dickinson added the comment: > The Imaginary type could help to solve other "gotchas". Yes, it's an attractive proposition from many angles: e.g., multiplying by 1j could do the correct quarter-turn rotation in the complex plane, keeping all signs correct, so that multiplying a complex

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The Imaginary type could help to solve other "gotchas". For example, in Python >>> complex(0, float('inf')) * 1 (nan+infj) But in C++ you will get the real component 0, because multiplication of complex and real numbers is component wise. With the

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-13 Thread Mark Dickinson
Mark Dickinson added the comment: See also #25839, #22548; there's lot of discussion of the core issue on those tickets. As Serhiy says, the only reasonable "true" fix would be to have 1j be a genuine imaginary literal, but that's a lot of work and potential disruption (not just to core

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is a known issue, but I have no references to previous discussions. Outputting numbers with decimal point will not help in case of complex(-0.0, 1.0). Maybe the only way to solve this problem is to implement special Imaginary type (as a subclass of

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: Would we be willing to consider an enhancement to have complex numbers always display using float format rather than ints? 1+1j --> 1.0+1.0j We could still suppress an unsigned real zero: 1j --> 1.0j but negative zero would show: -(1j) -->

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: The docs for complex literals¹ could be improved to show that: -1j is interpreted as -complex(0.0, 1.0) giving a real component of -0.0 and an imaginary component of -1.0 and that: 0-1j is interpreted as 0.0-complex(0.0, 1.0) giving a

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-12 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-12 Thread Josh Rosenberg
Josh Rosenberg added the comment: The final entry is identical to the second to last, because ints have no concept of -0. If you used a float literal, it would match the first two: >>> -0.-1j (-0-1j) I suspect the behavior here is due to -1j not actually being a literal on its own; it's

[issue40269] Inconsistent complex behavior with (-1j)

2020-04-12 Thread Rushil Udani
New submission from Rushil Udani : In a Python REPL: >>> -1j (-0-1j) >>> (-1j) (-0-1j) >>> 0-1j -1j >>> -0-1j -1j This is clearly inconsistent behavior! -1j and (-1j) should report as -1j, as the other two do. -- components: Interpreter Core messages: 366276 nosy: rushilu priority: