diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2008-05-09 17:54:23 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2008-05-09 17:54:23 (GMT) |
commit | f8476c15730939c4ee64d94f08c2d6e40b09195d (patch) | |
tree | 4b2107074cba7baf8bec2ceff3a049dcf2698f9b /Lib | |
parent | 8bd5334a9e192bcd1c182574d585179bc9d8be2d (diff) | |
download | cpython-f8476c15730939c4ee64d94f08c2d6e40b09195d.zip cpython-f8476c15730939c4ee64d94f08c2d6e40b09195d.tar.gz cpython-f8476c15730939c4ee64d94f08c2d6e40b09195d.tar.bz2 |
Issue #2487. math.ldexp(x, n) raised OverflowError when n was large and
negative; fix to return an (appropriately signed) zero instead.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_math.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index c9eade3..a5c6f62 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -374,6 +374,24 @@ class MathTests(unittest.TestCase): self.assertEquals(math.ldexp(NINF, -213), NINF) self.assert_(math.isnan(math.ldexp(NAN, 0))) + # large second argument + for n in [10**5, 10L**5, 10**10, 10L**10, 10**20, 10**40]: + self.assertEquals(math.ldexp(INF, -n), INF) + self.assertEquals(math.ldexp(NINF, -n), NINF) + self.assertEquals(math.ldexp(1., -n), 0.) + self.assertEquals(math.ldexp(-1., -n), -0.) + self.assertEquals(math.ldexp(0., -n), 0.) + self.assertEquals(math.ldexp(-0., -n), -0.) + self.assert_(math.isnan(math.ldexp(NAN, -n))) + + self.assertRaises(OverflowError, math.ldexp, 1., n) + self.assertRaises(OverflowError, math.ldexp, -1., n) + self.assertEquals(math.ldexp(0., n), 0.) + self.assertEquals(math.ldexp(-0., n), -0.) + self.assertEquals(math.ldexp(INF, n), INF) + self.assertEquals(math.ldexp(NINF, n), NINF) + self.assert_(math.isnan(math.ldexp(NAN, n))) + def testLog(self): self.assertRaises(TypeError, math.log) self.ftest('log(1/e)', math.log(1/math.e), -1) |