Binary to mpz_t

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


I believe what you are looking for is 

mpz_import (check it out here)
http://www.swox.com/gmp/manual/Integer-Import-and-Export.html#Integer%20Import%20and%20Export

I believe that does what you want.

Signed
David McKen

--- James Buchanan <jamesb.au at ozemail.com.au> 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 swox.com
> https://gmplib.org/mailman/listinfo/gmp-discuss


=====
Signed 
David Mcken

Life Sucks
Live with it

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


More information about the gmp-discuss mailing list