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 important in complex arithmetic, for example it is conventional and useful that sqrt(-1+0i) ==> +i and sqrt(-1-0i) ==> -i. Python currently allows the floating point number -0.0 to be entered as a literal:
>>> -0.0 -0.0 Complex floating point numbers in python also can hold negative zero components, as shown in their repr() >>> -(1+0j) (-1-0j) However they cannot be input directly as literals; it is currently necessary to use the above construction. Unfortunately the output of the repr() cannot be used as a string literal to obtain the same number: >>> (-1-0j) (-1+0j) except, in contrast: >>> complex('-1-0j') (-1-0j) The literal -1-0j should yield a complex number with negative zero imaginary part. Note also that complex literals with negative zero real parts have the same bug, e.g. -0+1j is not the same as -(0-1j) ---------- components: Interpreter Core messages: 256209 nosy: Mark Lundeberg priority: normal severity: normal status: open title: negative zero components are ignored in complex number literals type: behavior versions: Python 2.7, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25839> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com