mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-121485: Always use 64-bit integers for integers bits count (GH-121486)
Use 64-bit integers instead of platform specific size_t or Py_ssize_t to represent the number of bits in Python integer.
This commit is contained in:
parent
58ce131037
commit
32c7dbb2bc
13 changed files with 187 additions and 111 deletions
|
|
@ -1120,6 +1120,15 @@ class MathTests(unittest.TestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
math.isqrt(value)
|
||||
|
||||
@support.bigmemtest(2**32, memuse=0.85)
|
||||
def test_isqrt_huge(self, size):
|
||||
if size & 1:
|
||||
size += 1
|
||||
v = 1 << size
|
||||
w = math.isqrt(v)
|
||||
self.assertEqual(w.bit_length(), size // 2 + 1)
|
||||
self.assertEqual(w.bit_count(), 1)
|
||||
|
||||
def test_lcm(self):
|
||||
lcm = math.lcm
|
||||
self.assertEqual(lcm(0, 0), 0)
|
||||
|
|
@ -1261,6 +1270,13 @@ class MathTests(unittest.TestCase):
|
|||
self.assertEqual(math.log(INF), INF)
|
||||
self.assertTrue(math.isnan(math.log10(NAN)))
|
||||
|
||||
@support.bigmemtest(2**32, memuse=0.2)
|
||||
def test_log_huge_integer(self, size):
|
||||
v = 1 << size
|
||||
self.assertAlmostEqual(math.log2(v), size)
|
||||
self.assertAlmostEqual(math.log(v), size * 0.6931471805599453)
|
||||
self.assertAlmostEqual(math.log10(v), size * 0.3010299956639812)
|
||||
|
||||
def testSumProd(self):
|
||||
sumprod = math.sumprod
|
||||
Decimal = decimal.Decimal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue