mpz_get_d_2exp exponent

Paul Zimmermann Paul.Zimmermann at loria.fr
Wed Jun 3 09:28:07 CEST 2009


       Rob,

> From: sisyphus1 at optusnet.com.au
> Date: Wed, 03 Jun 2009 16:33:15 +1000
> 
> Hi,
> I was expecting that the exponent set by mpz_get_d_2exp would be an 'unsigned' value - but both the code and the documentation specify a 'signed long int. That exponent can never be set to a negative value, can it ? (I can't see how it could, but sometimes my vision isn't so good.)
> 
> Cheers,
> Rob

you are right. If OP is zero, then 0 is stored in EXP. If OP is non-zero,
truncating it will be still larger than 1 in absolute value, and since
D * 2^EXP = OP, and 0.5<=abs(D)<1, then 2^EXP = OP/D >= 2.

Thus unless OP is zero, you even have EXP >= 1.

Paul Zimmermann


More information about the gmp-discuss mailing list