Re: mpz_limbs interface

2014-02-06 Thread Niels Möller
ni...@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.

Re: mpz_limbs interface

2014-02-06 Thread Marc Glisse
On Thu, 6 Feb 2014, Niels Möller wrote: ni...@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

Re: mpz_limbs interface

2014-02-06 Thread Niels Möller
Marc Glisse marc.gli...@inria.fr writes: Why not return int, since int is what we use for _mp_size? int would be sufficient for all known float formats I guess. I choose long because that was the signed type closest to mp_bit_cnt_t. Is 53 really safe for non-IEEE double? Maybe something based

Re: mpz_limbs interface

2014-02-06 Thread Vincent Lefevre
On 2014-02-06 11:54:04 +0100, Niels Möller wrote: Marc Glisse marc.gli...@inria.fr writes: + ASSERT (d != 0.5*d); /* Exclude infinities */ That excludes more than infinities, it might also exclude FLT_TRUE_MIN, no? I would have expected that FLT_TRUE_MIN * 0.5 == 0.0. And then it's

Re: mpz_limbs interface

2014-02-06 Thread Niels Möller
Vincent Lefevre vinc...@vinc17.net writes: In rounding mode toward +inf (FE_UPWARD), FLT_TRUE_MIN * 0.5 gives FLT_TRUE_MIN. I see. You may need: ASSERT (d - d == 0); That should exclude both infinities and NaN:s, right? Regards, /Niels -- Niels Möller. PGP-encrypted email is

Re: mpz_limbs interface

2014-02-06 Thread Vincent Lefevre
On 2014-02-06 12:46:05 +0100, Niels Möller wrote: Vincent Lefevre vinc...@vinc17.net writes: You may need: ASSERT (d - d == 0); That should exclude both infinities and NaN:s, right? Yes. If you want to differentiate between NaN and infinities: d != d is true only for NaN. -- Vincent

Re: mpz_limbs interface

2014-02-06 Thread Niels Möller
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

Re: mpz_limbs interface

2014-02-06 Thread Marc Glisse
On Thu, 6 Feb 2014, Niels Möller wrote: 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,

Re: mpz_limbs interface

2014-02-06 Thread Niels Möller
Marc Glisse marc.gli...@inria.fr writes: On Thu, 6 Feb 2014, Niels Möller wrote: 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. But so far, we

Re: mpz_limbs interface

2014-02-06 Thread Marc Glisse
On Thu, 6 Feb 2014, Niels Möller wrote: Marc Glisse marc.gli...@inria.fr writes: Note that there exist standard functions like isfinite. But so far, we don't use any libm functions in gmp. True. * no slower then the _GMP_IEEE_FLOATS definition (which extracts the exponent via a

Re: mpz_limbs interface

2014-02-06 Thread Torbjorn Granlund
ni...@lysator.liu.se (Niels Möller) writes: Below is a patch to do this (and return value is long, not mp_bitcnt_t, since it needs to be signed). What do you think? I'm to busy to make an educated analysis. Why isn't __gmp_extract_double's style OK for mpn_set_d? Is its conventions