A question about mpz_out_str and mpz_out_raw output limitation
Fredrik Johansson
fredrik.johansson at gmail.com
Tue Jun 24 15:20:37 UTC 2014
On Mon, Jun 23, 2014 at 12:15 PM, Nikitin Kirill <kirill.nikitin at epfl.ch> wrote:
> Dear all,
>
> I'm currently working with large sets of public-key moduli using gmp-6.0.0 for arbitrary precision arithmetic. There is a need to multiple all unique primes from moduli together so final number is getting huge sometimes (the sets sometimes include about 10 000 000 moduli).
> I have encountered a problem that mpz_out_raw has a limitation for printing numbers to a file, precisely 2^31 bytes (mpz_inp_raw has the same accordingly). When numbers are bigger, the output is wrong (maybe shrunken). Therefore, I'm wondering if it is possible to remove this limitation in some way? and whether mpz_out_str (mpz_inp_str) has the same limitation?
> Please correct me if I'm wrong at some point. Thank you for any help!
I have encountered the same problem. Actually mpz_out_raw truncates
the size information to a 32-bit integer but still writes all the
bytes of output. So if you just write a single number to one file, you
can still recover it based on the file size (just not with
mpz_inp_raw). You could also try mpz_export / mpz_import.
Fredrik
More information about the gmp-discuss
mailing list