[PPL-devel] [Fwd: Re: mpz_get_d precision]

Roberto Bagnara bagnara at cs.unipr.it
Sat Feb 19 14:22:13 CET 2005



-------- Original Message --------
Subject: Re: mpz_get_d precision
Date: 18 Feb 2005 22:41:49 +0100
From: Torbjorn Granlund <tege at swox.com>
To: Roberto Bagnara <bagnara at cs.unipr.it>
CC: gmp-devel at swox.com
References: <20040430135004.GB31761 at papillon.inria.fr>	<87fzaluq5j.fsf at zip.com.au> <87u0yubm1p.fsf at zip.com.au>	<420F26AF.5040907 at cs.unipr.it>

Roberto Bagnara <bagnara at 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.

-- 
Torbjörn
_______________________________________________
gmp-devel mailing list
gmp-devel at swox.com
http://swox.com/mailman/listinfo/gmp-devel


-- 
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 PPL-devel mailing list