Problem with large values in GMP...

Torbjörn Granlund tg at gmplib.org
Thu Mar 17 09:16:25 UTC 2016


Here is what I think is going on.

The calculation of the expected result size of powering is not exact,
but a slight over-estimate.  That't not easy to fix without messing
around with very accurate logarithms.

Furthermore, when using 64-bit ABIs which are LLP64 (like Windoze-64)
the size calculation looks like it is prone to overflow.  On LP64 (as
opposed to LLP64) machines, overflow can happen but only when asking for
a calculation which will never fit in any computer's memory.

Giving systems like Windoze-64 a slightly larger range for mpz is not a
trivial task; it would require internal and externally visible typing
changes.  E.g., the externally visible mp_bitcnt_t is supposed to hold
the bitsize of any mpz number, and this type will become 32 bits under
LLP64.  It is not clear how to type it without losing portability.

Except for Windoze, LLP64 ABIs are fortunately rare these days.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-discuss mailing list