Binary to mpz_t

David McKen cic_3_b at
Sat Oct 25 09:28:12 CEST 2003

I believe what you are looking for is 

mpz_import (check it out here)

I believe that does what you want.

David McKen

--- James Buchanan < at> wrote:
> Hi everyone,
> I'd like to ask if anyone knows how I can slurp in binary data from
> a file
> and convert it into an mpz_t big int.  For example, I'd like to
> open a file
> in binary mode:
> f = fopen("file.bin", "rb");
> and suck in 512 bytes, i.e. a typical disk sector:
> unsigned char stuff[512];
> fread(stuff, sizeof(char), 512, f);
> and then use whatever's in stuff[] to make the big int.  I'd like
> it to
> interpret the 512-bit long bit pattern as an unsigned integer.  I'd
> also
> like to be able to write it back out as a 512-bit long bit pattern.
> How can I do this?
> Many Thanks,
> James
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at

David Mcken

Life Sucks
Live with it

Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

More information about the gmp-discuss mailing list