mpz_limbs interface

Marc Glisse marc.glisse at inria.fr
Thu Feb 6 10:39:13 UTC 2014


On Thu, 6 Feb 2014, Niels Möller wrote:

> nisse at lysator.liu.se (Niels Möller) writes:
>
>> For mpn_set_d, I think it would make some sense to have it return a
>> base-2 exponent, and write the mantissa to a few limbs. Number of limbs
>> would be a constant, part of the ABI, similar to LIMBS_PER_DOUBLE but
>> renamed for external use.
>>
>>   mp_bitcnt_t
>>   mpn_set_d (mp_limb_t rp[LIMBS_PER_BOUBLE], d);
>
> Below is a patch to do this (and return value is long, not mp_bitcnt_t,
> since it needs to be signed).

Thanks.

> What do you think?

(I haven't looked at it much yet)

Why not return int, since int is what we use for _mp_size?

Is 53 really safe for non-IEEE double? Maybe something based on 
DBL_MANT_DIG, assuming that FLT_RADIX==2?

I don't think we are still supporting gcc-2.8...

>From a performance POV, it may not be optimal to split the 
sign/infinity/nan/zero test from the rest, but I agree it makes the 
interface simpler.

> +   ASSERT (d != 0.5*d);	/* Exclude infinities */

That excludes more than infinities, it might also exclude FLT_TRUE_MIN, 
no?

-- 
Marc Glisse


More information about the gmp-devel mailing list