This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove GMP in favor of MPFR


At 09:17 AM 7/4/2004, Paul Brook wrote:

> > +/* Andy may have used biased exponents e = E + bias where bias = 1.
> > +   Single precision model numbers.  */
> >
> > I don't understand this comment, and the following defines are
> > inconsistent (some differ by one, others are the same).
> >
> > Is this a genuine error, or the difference between defining the valid
> > exponents as <= E vs. < E ?
>
> I'm looking at the July 1, 2004 revision of the IEEE-754 standard.
> Table 1a shows
>             p    emax   emin
> binary32    24    127   -126
> binary64    53   1023  -1022
> binary128  113  16383 -16382
>
> If you go to www.mpfr.org, and then go to the bottom of that
> page, you'll find a link to the IEEE 754 working group.  You
> can find PDFs of the current standard and the current proposed
> revision.  Of course, these PDFs are to be used in contributing
> comments to the IEEE 754 working group.
>
> I've retained the original emin and emax for single (128,-125)
> and double (1024,-1021) precision because I wasn't sure if the
> computations of range, precision, epsilon, huge, and tiny depend
> on these values in some unusual way.  This is on my list of
> things to check against the draft F2003 standard.

I think these numbers come from gcc/real.c. However reading a bit further
uncovers the following comment:
      /* Recall that IEEE numbers are interpreted as 1.F x 2**exp,
         whereas the intermediate representation is 0.F x 2**exp.

That should be 0.5F x 2**exp


Which means we're off by one. */

Yes, IEEE and Fortran differ by 1 in the definition of exponent. C <float.h> agrees with Fortran. Source code which uses the C and Fortran facilities must not have to be concerned with the different IEEE definition. You can't even tell from the raw number format. To IEEE, the bias is different by 1 from the bias which goes with the Fortran/C definition.


There's also Note 13.4 from the standard, which looks a lot like ieee single
precision format.

Based on this I think the correct values are 127, -126 and 1023, -1022.

Ideally we would generate these tables automatically for different targets,
but that's a different matter.

Paul

Tim Prince



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]