gmp
gmp copied to clipboard
Support storing integers larger than 2^31 bytes?
Hi,
We're using gmp to run on large inputs, and we are wondering if it is possible for gmp to support storing integers larger than 2^31 bytes.
Thank you!
5+ billion digit number :open_mouth:
This will depend entirely on libgmp
.
I found a message on the mailing list from 2012 which states
The hard limit for mpz is 2^32-1 bits, on a 32-bit machine, and (as Paul says) about 2^37-64 bits on a 64-bit machine.
This library uses what libgmp calls mpz
to store its Int
type.
So assuming you are using a 64 bit machine you should be good for ~2^34 bytes or numbers of up to 41 billion decimal digits..
It is possible that this limit has been raised since 2012 - I don't know!
Hello, this can be patched for binary input/output. See https://github.com/zugzwang/batchgcd, which contains an update from the patch provided in factorable.net. I am not in need of this (and I don't think there are many use cases out there - cryptography, and I recall reading something related in record computations of the partition function), but I was wondering if this is feasible in your current library.
@zugzwang you can certainly output the integers as binary - see the Bytes method - I'm not sure how efficient it is though!
Hi @ncw, I was referring to the disk input/output of binary numbers larger than 2**31
(representing larger numbers is of course fine). This can only be achieved in gmp
with the patch, so I was only wondering if you had a way around it.
@zugzwang not currently!