mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606)
Change the behaviour of `math.pow(0.0, -math.inf)` and `math.pow(-0.0, -math.inf)` to return positive infinity instead of raising `ValueError`. This makes `math.pow` consistent with the built-in `pow` (and the `**` operator) for this particular special case, and brings the `math.pow` special-case handling into compliance with IEEE 754.
This commit is contained in:
parent
3ec3ee7d2e
commit
4a42cebf6d
6 changed files with 21 additions and 11 deletions
|
@ -1230,7 +1230,7 @@ class MathTests(unittest.TestCase):
|
|||
self.assertRaises(ValueError, math.pow, 0., -2.)
|
||||
self.assertRaises(ValueError, math.pow, 0., -2.3)
|
||||
self.assertRaises(ValueError, math.pow, 0., -3.)
|
||||
self.assertRaises(ValueError, math.pow, 0., NINF)
|
||||
self.assertEqual(math.pow(0., NINF), INF)
|
||||
self.assertTrue(math.isnan(math.pow(0., NAN)))
|
||||
|
||||
# pow(INF, x)
|
||||
|
@ -1256,7 +1256,7 @@ class MathTests(unittest.TestCase):
|
|||
self.assertRaises(ValueError, math.pow, -0., -2.)
|
||||
self.assertRaises(ValueError, math.pow, -0., -2.3)
|
||||
self.assertRaises(ValueError, math.pow, -0., -3.)
|
||||
self.assertRaises(ValueError, math.pow, -0., NINF)
|
||||
self.assertEqual(math.pow(-0., NINF), INF)
|
||||
self.assertTrue(math.isnan(math.pow(-0., NAN)))
|
||||
|
||||
# pow(NINF, x)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue