Skip to content

Commit 5edc606

Browse files
committed
Add guards to bypass the test when double rounding can occur.
1 parent 58cbdbb commit 5edc606

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Lib/test/test_math.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,20 @@ def testHypot(self):
803803
scale = FLOAT_MIN / 2.0 ** exp
804804
self.assertEqual(math.hypot(4*scale, 3*scale), 5*scale)
805805

806+
@requires_IEEE_754
807+
@unittest.skipIf(HAVE_DOUBLE_ROUNDING,
808+
"hypot() loses accuracy on machines with double rounding")
806809
def testHypotAccuracy(self):
807810
# Verify improved accuracy in cases that were known to be inaccurate.
811+
#
812+
# The new algorithm's accuracy depends on IEEE 754 arithmetic
813+
# guarantees, on having the usual ROUND HALF EVEN rounding mode, on
814+
# the system not having double rounding due to extended precision,
815+
# and on the compiler maintaining the specified order of operations.
816+
#
817+
# This test is known to succeed on most of our builds. If it fails
818+
# some build, we either need to add another skipIf if the cause is
819+
# identifiable; otherwise, we can remove this test entirely.
808820

809821
hypot = math.hypot
810822
Decimal = decimal.Decimal
@@ -835,7 +847,7 @@ def testHypotAccuracy(self):
835847
('0x1.1243a50751fd4p+29', '0x1.a5a10175622d9p+29'),
836848
('0x1.57a8596e74722p+30', '0x1.42d1af9d04da9p+30'),
837849

838-
# Cases with 1 ulp error in version fff3c28052e6b0750d6218e00acacd2fded4991a
850+
# Cases with 1 ulp error in version fff3c28052e6b0
839851
('0x1.ee7dbd9565899p+29', '0x1.7ab4d6fc6e4b4p+29'),
840852
('0x1.5c6bfbec5c4dcp+30', '0x1.02511184b4970p+30'),
841853
('0x1.59dcebba995cap+30', '0x1.50ca7e7c38854p+29'),

0 commit comments

Comments
 (0)