gmp 4.2.4 - mpf_add two large negative floats - strange result

Vincent Lefevre vincent at vinc17.org
Thu Jan 22 01:25:00 CET 2009


On 2009-01-22 10:51:22 +1100, Sisyphus wrote:
> Duh .... 53 bits is the default for mpfr (I think),

Yes (this is the IEEE-754 double precision), though you should not
use the default precision.

> but the default for gmp's mpf type is 64 (on my build, at least).

In GMP, the precision is a multiple of the size of a limb in bits
(so, in practice, a multiple of 32 or 64). The default precision
is __GMPF_BITS_TO_PREC(53), where:

/* __GMPF_BITS_TO_PREC applies a minimum 53 bits, rounds upwards to a whole
   limb and adds an extra limb.  __GMPF_PREC_TO_BITS drops that extra limb,
   hence giving back the user's size in bits rounded up.  Notice that
   converting prec->bits->prec gives an unchanged value.  */
#define __GMPF_BITS_TO_PREC(n)                                          \
  ((mp_size_t) ((__GMP_MAX (53, n) + 2 * GMP_NUMB_BITS - 1) / GMP_NUMB_BITS))
#define __GMPF_PREC_TO_BITS(n) \
  ((unsigned long) (n) * GMP_NUMB_BITS - GMP_NUMB_BITS)

-- 
Vincent Lefèvre <vincent at vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


More information about the gmp-discuss mailing list