mpz_get_d precision
Roberto Bagnara
bagnara at cs.unipr.it
Sun Feb 13 11:06:39 CET 2005
Kevin Ryde wrote:
> Updated words on the get_d functions will be as follows.
>
> The bits about hardware traps are because I don't want to try to
> guarantee they will or won't occur. I'm fairly sure in the past some
> cases trapped and some not, so this should be a no-change.
>
>
> -- Function: double mpz_get_d (mpz_t OP)
> Convert OP to a `double', truncating if necessary (ie. rounding
> towards zero).
>
> If the exponent from the conversion is too big, the result is
> system dependent. An infinity is returned where available. A
> hardware overflow trap may or may not occur.
>
> -- Function: double mpz_get_d_2exp (signed long int *EXP, mpz_t OP)
> Convert OP to a `double', truncating if necessary (ie. rounding
> towards zero), and returning the exponent separately.
>
> The return value is in the range 0.5<=abs(D)<1 and the exponent is
> stored to `*EXP'. D * 2^EXP is the (truncated) OP value. If OP
> is zero, the return is 0.0 and 0 is stored to `*EXP'.
>
> This is similar to the standard C `frexp' function (*note
> Normalization Functions: (libc)Normalization Functions.).
>
>
> -- Function: double mpq_get_d (mpq_t OP)
> Convert OP to a `double', truncating if necessary (ie. rounding
> towards zero).
>
> If the exponent from the conversion is too big or too small to fit
> a `double' then the result is system dependent. For too big an
> infinity is returned when available. For too small 0.0 is
> returned. Hardware overflow, underflow and denorm traps may or
> may not occur.
>
>
> -- Function: double mpf_get_d (mpf_t OP)
> Convert OP to a `double', truncating if necessary (ie. rounding
> towards zero).
>
> If the exponent in OP is too big or too small to fit a `double'
> then the result is system dependent. For too big an infinity is
> returned when available. For too small 0.0 is returned. Hardware
> overflow, underflow and denorm traps may or may not occur.
>
> -- Function: double mpf_get_d_2exp (signed long int *EXP, mpf_t OP)
> Convert OP to a `double', truncating if necessary (ie. rounding
> towards zero), and with an exponent returned separately.
>
> The return value is in the range 0.5<=abs(D)<1 and the exponent is
> stored to `*EXP'. D * 2^EXP is the (truncated) OP value. If OP
> is zero, the return is 0.0 and 0 is stored to `*EXP'.
>
> This is similar to the standard C `frexp' function (*note
> Normalization Functions: (libc)Normalization Functions.).
I see this extra documentation is not present in the GMP 4.1.4 distribution.
Since I am very interested about these guarantees (in particular
for what concerns mpz_get_d and mpq_get_d), I would like to ask:
1) Do these words apply to GMP 4.1.4?
2) (In any case) Will they apply to GMP 4.2?
Many thanks in advance,
Roberto
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it
More information about the gmp-devel
mailing list