Vincent Lefevre <vinc...@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 #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). * 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? Ah, and about mpn_get_d. Maybe it would make sense to drop the sign argument, and and use the sign of the size argument, or limit to non-negative numbers only (it's trivial for the caller to negate the output when desired). Regards, /Niels -- Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance. _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel