A question about mpz_out_str and mpz_out_raw output limitation
David Gillies
daggillies at gmail.com
Tue Jun 24 15:41:53 UTC 2014
>From the manual entry for mpz_out_raw(): "The integer is written in a
portable format, with 4 bytes of size information, and that many bytes of
limbs." So that would seem to limit it to 2^35 bits.
On Tue, Jun 24, 2014 at 9:20 AM, Fredrik Johansson <
fredrik.johansson at gmail.com> wrote:
> 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
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>
--
David Gillies
San Jose
Costa Rica
More information about the gmp-discuss
mailing list