gmpy icon indicating copy to clipboard operation
gmpy copied to clipboard

mpz gives wrong result with very large exponent .

Open shortjonescipher opened this issue 4 years ago • 1 comments

Only the first of these expressions gives the correct result:-

Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32
>>> from gmpy2 import mpz, bit_length
>>> bit_length(2 ** 10439860591)
10439860592
>>> bit_length(2 ** mpz(10439860591))
1849926000
>>> bit_length(mpz(2) ** mpz(10439860591))
1849926000
>>> bit_length(mpz(2) ** 10439860591)
1849926000

mp_version() is 'MPIR 2.6.0'.

shortjonescipher avatar Mar 16 '20 07:03 shortjonescipher

This is a quirk caused by Windows using 32-bit longs even on a 64-bit platform. I'll try to get it fixed soon.

casevh avatar Apr 10 '20 07:04 casevh