[issue22548] Bogus parsing of negative zeros in complex literals

2020-04-19 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: -18927 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue22548] Bogus parsing of negative zeros in complex literals

2020-04-19 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +serhiy.storchaka nosy_count: 3.0 -> 4.0 pull_requests: +18927 pull_request: https://github.com/python/cpython/pull/19593 ___ Python tracker _

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Mark Dickinson
Mark Dickinson added the comment: > It doesn't cover the "sum with like signs" Ah, sorry, yes it does; it's in the previous paragraph. """ [...] the sign of a sum, or of a difference x−y regarded as a sum x+(−y), differs from at most one of the addends’ signs """ --

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Mark Dickinson
Mark Dickinson added the comment: > Oops, I get it now. Okay. :-) Just for the record, for anyone encountering this issue in the future, here's the relevant extract from section 6.3 of IEEE 754-2008: """ When the sum of two operands with opposite signs (or the difference of two operands with

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: Yes, the last part is ok. It's the preceding parts that are a bit surprising. -- ___ Python tracker ___

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: Oops, I get it now. Sorry. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Mark Dickinson
Mark Dickinson added the comment: Nope, no float issue here. :-) Which part of the output do you think is wrong? Your last (z - z) is doing ((-0.0) - (-0.0)), not (-0.0 - 0.0). This is all following the IEEE 754 rules. -- ___ Python tracker

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: FTR, a similar issue with regular floats: >>> -0.0-0.0 -0.0 >>> (-0.0)-0.0 -0.0 >>> z = -0.0 >>> z - z 0.0 -- ___ Python tracker ___ __

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Mark Dickinson
Mark Dickinson added the comment: P.S. The C standardisation folks tried to introduce the Imaginary type (optional for a conforming implementation) to get around exactly this type of problem, but it doesn't seem to have caught on in most mainstream compilers. -- _

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Mark Dickinson
Mark Dickinson added the comment: Sorry; that should be: complex(-0.0, 0.0) - complex(0.0, 0.0) The imaginary part is then worked out as (0.0 - 0.0), which (in all rounding modes but round-towards-negative) is 0.0. -- ___ Python tracker

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Mark Dickinson
Mark Dickinson added the comment: This is not a bug, but a known and difficult-to-avoid issue with signed zeros and creating complex numbers from real and imaginary parts. The safe way to do it is to use the `complex(real_part, imag_part)` construction. In the first example, you're subtractin

[issue22548] Bogus parsing of negative zeros in complex literals

2014-10-03 Thread Antoine Pitrou
New submission from Antoine Pitrou: This may be a parser limitation... >>> z = -0.-0.j >>> z (-0+0j) >>> z.imag 0.0 >>> z = 0.-0.j >>> z.imag 0.0 -- components: Interpreter Core messages: 228343 nosy: benjamin.peterson, mark.dickinson, pitrou priority: low severity: normal status: open