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 belopolsky
Recipients belopolsky
Date 2011-04-28.23:44:12
SpamBayes Score 0.0006285884
Marked as misclassified No
Message-id <1304034252.98.0.883023969041.issue11949@psf.upfronthosting.co.za>
In-reply-to
Content
Actually, my first attempt to fix the test was faulty.  The correct logic seems to be

+def is_negative_zero(x):
+    return x == 0 and math.copysign(1, x) < 0
+
+def almost_equal(value, expected):
+    if math.isfinite(expected) and math.isfinite(value):
+        if is_negative_zero(expected):
+            return is_negative_zero(value)
+        if is_negative_zero(value):
+            return is_negative_zero(expected)
+        return abs(value-expected) <= eps
+    if math.isnan(expected):
+        return math.isnan(value)
+    return value == expected
+
 class MathTests(unittest.TestCase):
+    
+    def test_xxx(self):
+        self.assertTrue(is_negative_zero(-0.0))
+        self.assertFalse(almost_equal(0.0, -0.0))
 
     def ftest(self, name, value, expected):
-        if abs(value-expected) > eps:
+        if not almost_equal(value, expected):

Now, the attached patch has two failures:

AssertionError: fmod(-10,1) returned -0.0, expected 0

and 

AssertionError: sqrt0002:sqrt(-0.0) returned -0.0, expected 0.0

The first seems to be a typo in the test, but I would not expect sqrt(-0.0) to return -0.0.  Does anyone know what the relevant standard says?
History
Date User Action Args
2011-04-28 23:44:13belopolskysetrecipients: + belopolsky
2011-04-28 23:44:12belopolskysetmessageid: <1304034252.98.0.883023969041.issue11949@psf.upfronthosting.co.za>
2011-04-28 23:44:12belopolskylinkissue11949 messages
2011-04-28 23:44:12belopolskycreate