reading binary file content into an mpz_t variable

Gabriel Risterucci gabriel.risterucci at univmed.fr
Mon Jan 17 10:29:39 CET 2011


2011/1/17 foxmuldrster at yahoo.com <foxmuldrster at yahoo.com>

> Erick,
>
> I'm typing all this on my phone, and am also a relative GMP newbie, surely
> unable to answer these questions as skillfully as the others  here (should
> they ever choose to do so), but to my understanding:
>
> 1) Find out how many bits you'll need (file size * 8 most likely),
>
> 2) Initialize your GMP variable to that many bits of precision,
>
> 3) fread your raw file to that member variable which is the pointer (am on
> phone and do not remember its name  off the top of my head),
>

I'm not sure that this method is really stable regarding stability in future
GMP version, or use on different platforms...
Why can't the mpz_export() and mpz_import() function be used here ? They
seem to do exactly what's needed, from my understanding.


More information about the gmp-discuss mailing list