summaryrefslogtreecommitdiff
path: root/Lib/test/test_float.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-01-21 21:54:47 +0000
committerMark Dickinson <dickinsm@gmail.com>2008-01-21 21:54:47 +0000
commit2bebadfe517c8c3c5a24f246eb44b5fa9dfc2cf3 (patch)
treee3135aa1d1c6174cde600d3fba6579dd831a9362 /Lib/test/test_float.py
parent78d50ccdf93d98d39fa7ec741a401d6bf2db815a (diff)
downloadcpython-git-2bebadfe517c8c3c5a24f246eb44b5fa9dfc2cf3.tar.gz
Issue 1678380: fix a bug identifying -0.0 and 0.0
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r--Lib/test/test_float.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index fb47db8eb0..2f0d7840c8 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -99,6 +99,27 @@ class IEEEFormatTestCase(unittest.TestCase):
('<f', LE_FLOAT_NAN)]:
struct.unpack(fmt, data)
+ if float.__getformat__("double").startswith("IEEE"):
+ def test_negative_zero(self):
+ import math
+ def pos_pos():
+ return 0.0, math.atan2(0.0, -1)
+ def pos_neg():
+ return 0.0, math.atan2(-0.0, -1)
+ def neg_pos():
+ return -0.0, math.atan2(0.0, -1)
+ def neg_neg():
+ return -0.0, math.atan2(-0.0, -1)
+ self.assertEquals(pos_pos(), neg_pos())
+ self.assertEquals(pos_neg(), neg_neg())
+
+ if float.__getformat__("double").startswith("IEEE"):
+ def test_underflow_sign(self):
+ import math
+ # check that -1e-1000 gives -0.0, not 0.0
+ self.assertEquals(math.atan2(-1e-1000, -1), math.atan2(-0.0, -1))
+ self.assertEquals(math.atan2(float('-1e-1000'), -1),
+ math.atan2(-0.0, -1))
def test_main():
test_support.run_unittest(