Limits of mpz_t size

83 views
Skip to first unread message

Gaj Satha

unread,
Mar 10, 2020, 4:56:21 AM3/10/20
to mpir-devel
Hi:

Are there any limits on the size of mpz_t in MPIR (Other than availble memory)?

I came to know that GNU GMP had limit of 41 billion on mpz_t sometime back (as per https://gmplib.org/list-archives/gmp-discuss/2016-July/006013.html), which they plan to remove but I don't know if it has been removed.

Please let me know. I need to calculate digits to 50 trillion.

Gaj


Bill Hart

unread,
Mar 10, 2020, 4:57:38 AM3/10/20
to mpir-devel
The limits in MPIR are the same.

In order to get around the limit, you can use the mpn layer of functions.

--
You received this message because you are subscribed to the Google Groups "mpir-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpir-devel/6a7df5d9-d3cb-451e-a249-d8ec5c309c21%40googlegroups.com.

Gaj Satha

unread,
Oct 27, 2020, 12:58:20 AM10/27/20
to mpir-...@googlegroups.com

Is it correct in saying that these limits (41 billion) is related to sizeof(int) = 4?

My machine has sizeof(int) = 8, so I can allocate much more than 4GB using malloc. Will I still suffer from this limit of I can go much beyond it?

Bill Hart

unread,
Oct 27, 2020, 1:30:30 AM10/27/20
to mpir-devel
No it's 2^37 on a 64 bit machine. This is due to the 32 bit type used
for the limb count in the mpz_t struct.

If you want to use larger integers, use the mpn functions as I explained.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mpir-devel/b4a3cdaf-ee75-a07b-2d48-314c2f3ed241%40gmail.com.
Reply all
Reply to author
Forward
0 new messages