Creating mpz_t from binary data

Marc Glisse marc.glisse at
Wed Mar 17 16:42:06 CET 2010

On Wed, 17 Mar 2010, Saju Pillai wrote:

> I am new to GMP. I receive a multi precision big endian integer represented 
> in two's complement. I am on a little endian machine. How can I create a 
> mpz_t using this data ?
> Will reversing the data bytes to create a little endian representation and 
> calling mpz_set_str(rop, data, 2) work ?. Since this is binary data,  NULs 
> may occur anywhere in the data. How do you suggest I proceed ?
> The mpint data type described at 
> (SSH architecture rfc) is the data format I am dealing with.


did you try ?

Marc Glisse

More information about the gmp-discuss mailing list