summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-05-23 12:07:36 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-05-23 12:07:36 (GMT)
commitbadd7da622460b8dd8405545f59da1e2c0ef79e6 (patch)
tree4d7d4238b9de575fef13e5ecb79e26805fee27a3 /Lib/test/test_math.py
parent2d593cc679534f11367b2dffcabb6e41ecc72ce8 (diff)
downloadcpython-badd7da622460b8dd8405545f59da1e2c0ef79e6.zip
cpython-badd7da622460b8dd8405545f59da1e2c0ef79e6.tar.gz
cpython-badd7da622460b8dd8405545f59da1e2c0ef79e6.tar.bz2
Skip math.sum tests on non IEEE 754 platforms, and on IEEE 754 platforms
that exhibit the problem described in issue #2937.
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index cc30081..095e657 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -631,6 +631,22 @@ class MathTests(unittest.TestCase):
self.assert_(math.isnan(math.sqrt(NAN)))
def testSum(self):
+ # math.sum relies on exact rounding for correct operation.
+ # There's a known problem with IA32 floating-point that causes
+ # inexact rounding in some situations, and will cause the
+ # math.sum tests below to fail; see issue #2937. On non IEEE
+ # 754 platforms, and on IEEE 754 platforms that exhibit the
+ # problem described in issue #2937, we simply skip the whole
+ # test.
+
+ if not float.__getformat__("double").startswith("IEEE"):
+ return
+
+ # on IEEE 754 compliant machines, both of the expressions
+ # below should round to 10000000000000002.0.
+ if 1e16+2.999 != 1e16+2.9999:
+ return
+
# Python version of math.sum algorithm, for comparison
def msum(iterable):
"""Full precision sum of values in iterable. Returns the value of