Integers conversions

Marc Glisse marc.glisse at
Tue Sep 27 11:39:16 CEST 2011

On Tue, 27 Sep 2011, Zdenek Prikryl wrote:

> Why the mpz_get_si() returns wrong value? It should return -1 (0xffffffff)?

Does the documentation answer your question?

— Function: signed long int mpz_get_si (mpz_t op)

     If op fits into a signed long int return the value of op. Otherwise 
return the least significant part of op, with the same sign as op.

     If op is too big to fit in a signed long int, the returned result is 
probably not very useful. To find out if the value will fit, use the 
function mpz_fits_slong_p.

Marc Glisse

More information about the gmp-discuss mailing list