This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Mark Lundeberg
Recipients Mark Lundeberg
Date 2015-12-11.08:44:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1449823499.05.0.146335841063.issue25839@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2015-12-11 08:44:59Mark Lundebergsetrecipients: + Mark Lundeberg
2015-12-11 08:44:59Mark Lundebergsetmessageid: <1449823499.05.0.146335841063.issue25839@psf.upfronthosting.co.za>
2015-12-11 08:44:59Mark Lundeberglinkissue25839 messages
2015-12-11 08:44:58Mark Lundebergcreate