reading binary file content into an mpz_t variable

foxmuldrster at foxmuldrster at
Mon Jan 17 10:39:44 CET 2011

They very possibly can and should be used. I do not know.

As I say, I am a relative newbie and there are those on this list FAR better  
equipped to respond.

- Rick

-----Original message-----
From: Gabriel Risterucci <gabriel.risterucci at>
To: "foxmuldrster at" <foxmuldrster at>
Cc: Erick Paquin <info at>, gmp-discuss at
Sent: Mon, Jan 17, 2011 09:29:54 GMT+00:00
Subject: Re: reading binary file content into an mpz_t variable

2011/1/17 foxmuldrster at <foxmuldrster at>

> 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