bpo-45917: Add math.exp2() method - return 2 raised to the power of x (GH-29829)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
This commit is contained in:
Gideon 2021-11-29 12:55:43 -06:00 committed by GitHub
parent c1f93f0d37
commit 6266e4af87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 0 deletions

View file

@ -501,6 +501,17 @@ class MathTests(unittest.TestCase):
self.assertTrue(math.isnan(math.exp(NAN)))
self.assertRaises(OverflowError, math.exp, 1000000)
def testExp2(self):
self.assertRaises(TypeError, math.exp2)
self.ftest('exp2(-1)', math.exp2(-1), 0.5)
self.ftest('exp2(0)', math.exp2(0), 1)
self.ftest('exp2(1)', math.exp2(1), 2)
self.ftest('exp2(2.3)', math.exp2(2.3), 4.924577653379665)
self.assertEqual(math.exp2(INF), INF)
self.assertEqual(math.exp2(NINF), 0.)
self.assertTrue(math.isnan(math.exp2(NAN)))
self.assertRaises(OverflowError, math.exp2, 1000000)
def testFabs(self):
self.assertRaises(TypeError, math.fabs)
self.ftest('fabs(-1)', math.fabs(-1), 1)