Binary to mpz_t

James Buchanan jamesb.au at ozemail.com.au
Sun Oct 26 02:59:50 CEST 2003


THANKYOU!!!

:-)

Yes it is exactly what I want!  Cheers!  (Don't know why I didn't see it.)

--James


----- Original Message -----
From: "David McKen" <cic_3_b at yahoo.com>
To: "James Buchanan" <jamesb.au at acm.org>; <gmp-discuss at swox.com>
Sent: Sunday, October 26, 2003 1:28 AM
Subject: Re: Binary to mpz_t


> 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%20Impo
rt%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