mpz_get_ld

Marc Glisse marc.glisse at inria.fr
Mon Jun 18 22:32:06 CEST 2012


On Mon, 18 Jun 2012, Zimmermann Paul wrote:

> I am contributing the following function:
>
> long double
> mpz_get_ld (mpz_t z)
> {
>  double h, l;
>  mpz_t tmp;
>
>  h = mpz_get_d (z);
>  mpz_init (tmp);
>  mpz_set_d (tmp, h);
>  mpz_sub (tmp, tmp, z);
>  l = mpz_get_d (tmp);
>  mpz_clear (tmp);
>  return (long double) h + (long double) l;
> }

If the function mpz_get_ld is provided, I expect it to work for the whole 
(exponent) range of long double value, not just the range of double. 
Should we first do something about large z, then apply your method and fix 
the result with ldexpl?

-- 
Marc Glisse


More information about the gmp-devel mailing list