This is the mail archive of the
`fortran@gcc.gnu.org`
mailing list for the GNU Fortran 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] |

*From*: jerry DeLisle <jvdelisle at charter dot net>*To*: Thomas Henlich <thenlich at users dot sourceforge dot net>*Cc*: gfortran <fortran at gcc dot gnu dot org>, Janne Blomqvist <blomqvist dot janne at gmail dot com>*Date*: Tue, 14 Jun 2011 19:00:29 -0700*Subject*: Re: [patch, libgfortran] PR48906 Wrong rounding results with -m32*References*: <4DE8D8D6.5030506@charter.net> <4DF25409.1080509@charter.net> <BANLkTim_o8bM6bJyJxYbKW7y=kJe0fZ2ug@mail.gmail.com> <BANLkTikMUeELyUbHnbf_AL49xnfKVzD4qg@mail.gmail.com> <4DF6E8CF.4070401@charter.net> <BANLkTi=M27D1pMJzXezw3Szvfuj=QG6ugQ@mail.gmail.com>

On Tue, Jun 14, 2011 at 06:51, jerry DeLisle<jvdelisle@charter.net> wrote:It should be easy to implement:

After the switch between F and E editing, we just need to shift the decimal point and decrement the exponent. No new rounding is required, because we keep the number of significant digits.

OK, after a little bit of experimentation, I have arrived at the updated patch attached.

This has been regression tested and passes all test cases I am aware of. I also have included a new test case gcc/testsuite/gfortran.dg/fmt_g.f90.

OK for trunk?

I have reviewed your patch, and I noticed that you placed the digit-shifting code quite at the top of output_float(), where the final value of e is not even known. Due to rounding, e can be modified after this point, so your code will generate invalid output in some cases, for example:

print "(-2PG0)", nearest(0.1d0, -1.0d0) ! 1.0000000000000000E+001 expected .0099999999999999992E+001

Please put the code where at belongs, after the switch between F and E editing (based on the final value of e).

The same applies to the scale factor in general, e.g.

print "(-2pg12.3)", 0.096 ! 1.00E+01 expected 0.001E+02 print "(-1pg12.3)", 0.0996 ! 1.00E+00 expected 0.010E+01 print "(-2pg12.3)", 0.09996 ! 1.00E+01 expected 0.100 print "(-1pg12.3)", 0.09996 ! 1.00E+00 expected 0.100 print "(1pg12.3)", 0.099996 ! 1.000E-01 expected 0.100 print "(2pg12.3)", 0.099996 ! 10.00E-02 expected 0.100 print "(-2pg12.3)", 999.6 ! 0.100E+04 expected 0.001E+06 print "(-1pg12.3)", 999.6 ! 0.100E+04 expected 0.010E+05 print "(1pg12.3)", 999.6 ! 0.100E+04 expected 9.996E+02 print "(2pg12.3)", 999.6 ! 0.100E+04 expected 99.96E+01

Please revise your code to fix this. A working approach I have outlined in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48906#c28 and an (alpha) implementation is here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48906#c31

Yes, I tried the alpha approach and got quite a number of regressions in the test suite. This lead me to think it would be better to start at the point of fewest regressions and work from there.

**References**:**[patch, libgfortran] Wrong rounding results with -m32***From:*jerry DeLisle

**Re: [patch, libgfortran] PR48906 Wrong rounding results with -m32***From:*jerry DeLisle

**Re: [patch, libgfortran] PR48906 Wrong rounding results with -m32***From:*Janne Blomqvist

**Re: [patch, libgfortran] PR48906 Wrong rounding results with -m32***From:*Thomas Henlich

**Re: [patch, libgfortran] PR48906 Wrong rounding results with -m32***From:*jerry DeLisle

**Re: [patch, libgfortran] PR48906 Wrong rounding results with -m32***From:*Thomas Henlich

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |