
-------- Original Message -------- Subject: Re: mpz_get_d precision Date: 18 Feb 2005 22:41:49 +0100 From: Torbjorn Granlund tege@swox.com To: Roberto Bagnara bagnara@cs.unipr.it CC: gmp-devel@swox.com References: 20040430135004.GB31761@papillon.inria.fr 87fzaluq5j.fsf@zip.com.au 87u0yubm1p.fsf@zip.com.au 420F26AF.5040907@cs.unipr.it
Roberto Bagnara bagnara@cs.unipr.it writes:
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?
I don't know. Probably not.
2) (In any case) Will they apply to GMP 4.2?
Yes.