mini-gmp mpz_{get,set}_d not fully compatible with GMP

Niels Möller nisse at
Tue Mar 6 22:03:57 UTC 2018

Marc Glisse <marc.glisse at> writes:

> On Tue, 6 Mar 2018, Marco Bodrato wrote:
>> Which solutions do you suggest? I see 3 possible ways:
>> - removing the non "fully compatible" functions;
>> - adding them to the "with a few exceptions:" section;
>> - correct the behaviour of the functions...
> As discussed for instance last October, the generic, non-IEEE version
> of mpn_get_d has a similar issue. Maybe they could both be fixed at
> the same time with the same code?

For mini-gmp, it's highly desirable for the get_d function to be fully
compatible with gmp at least for the common case of standard IEEE
floats. I'm fine with documenting different behavior for obscure
floating point variants.

For GMP, it's desirable to fix also the non IEEE-version.

Can we rely on FLT_RADIX and DBL_MANT_DIG (float.h, see,
to get correct rounding at least as long as FLT_RADIX == 2 ?

If I recall earlier discussion correctly, we really need to know the
size of the mantissa, from the compiler or a configure check (and the
latter is not applicable to mini-gmp).


Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list