From: Thomas Henlich <thenlich@users.sourceforge.net>
To: jerry DeLisle <jvdelisle@charter.net>
Cc: gfortran <fortran@gcc.gnu.org>,
Janne Blomqvist <blomqvist.janne@gmail.com>,
gcc patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch, libgfortran] PR48906 Wrong rounding results with -m32
Date: Tue, 14 Jun 2011 08:30:00 -0000 [thread overview]
Message-ID: <BANLkTi=M27D1pMJzXezw3Szvfuj=QG6ugQ@mail.gmail.com> (raw)
In-Reply-To: <4DF6E8CF.4070401@charter.net>
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
Thomas
next prev parent reply other threads:[~2011-06-14 7:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-03 12:51 [patch, libgfortran] " jerry DeLisle
2011-06-10 17:39 ` [patch, libgfortran] PR48906 " jerry DeLisle
2011-06-11 8:24 ` Janne Blomqvist
2011-06-11 9:13 ` Thomas Henlich
2011-06-11 14:19 ` jerry DeLisle
2011-06-11 16:05 ` Thomas Henlich
2011-06-14 6:14 ` jerry DeLisle
2011-06-14 8:30 ` Thomas Henlich [this message]
2011-06-11 20:01 jvdelisle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTi=M27D1pMJzXezw3Szvfuj=QG6ugQ@mail.gmail.com' \
--to=thenlich@users.sourceforge.net \
--cc=blomqvist.janne@gmail.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jvdelisle@charter.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).