Skip to content

Commit df77e3d

Browse files
committed
Issue python#11188: In log2 tests, create powers of 2 using ldexp(1, n) instead of the less reliable 2.0**n.
1 parent 86e104a commit df77e3d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/test/test_math.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ def testLog1p(self):
653653
def testLog2(self):
654654
self.assertRaises(TypeError, math.log2)
655655
# Check that we get exact equality for log2 of powers of 2.
656-
actual = [math.log2(2.0**n) for n in range(-324, 1024)]
657-
expected = [float(n) for n in range(-324, 1024)]
656+
actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)]
657+
expected = [float(n) for n in range(-1074, 1024)]
658658
self.assertEqual(actual, expected)
659659

660660
# Check some integer values

0 commit comments

Comments
 (0)