mpz_limbs interface
Marc Glisse
marc.glisse at inria.fr
Thu Feb 6 12:43:04 UTC 2014
On Thu, 6 Feb 2014, Niels Möller wrote:
> Vincent Lefevre <vincent at vinc17.net> writes:
>
>> Yes. If you want to differentiate between NaN and infinities:
>> d != d is true only for NaN.
>
> I'm looking at the definition of DOUBLE_NAN_INF_ACTION in gmp-impl.h.
> Maybe it could be simplified to a single, unconditional, definition
Note that there exist standard functions like isfinite.
> #define DOUBLE_NAN_INF_ACTION(x, a_nan, a_inf) \
> do { \
> if (UNLIKELY ((x) - (x) != 0.0)) \
> { \
> if ((x) != (x)) { a_nan; } \
> else { a_inf; } \
> } \
> } while (0)
>
> Does any of the current three definitions have any advantage over the
> above portable one? I would hope that the above is
>
> * no slower then the _GMP_IEEE_FLOATS definition (which extracts the
> exponent via a union).
Are you sure about that? If x is a denormal, x-x may take a very long time
to compute.
> * equivalent to the NOP definition for VAX; then x - x != 0.0 should be
> always false, and the compiler ought to know.
>
> * faster than the generic version, which implies a sequence of three
> (false) tests in the common case.
>
> I'm tempted to
>
> 1. Replace the DOUBLE_NAN_INF_ACTION macro.
>
> 2. Check in the mpn_set_d changes (possibly with smaller tweaks).
>
> 3. Make mpn_get_d public, and document both functions.
>
> Ok? Or should this wait until after 5.2?
I would have been in favor of avoiding new features less than a couple
months before the release, but since there are already plenty of *sec*
changes going on...
--
Marc Glisse
More information about the gmp-devel
mailing list