[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 Dominique d'Humieres changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #30 from Dominique d'Humieres --- What remains in this PR is handled by pr59836 (patch coming). Closing as duplicate. *** This bug has been marked as a duplicate of bug 59836 ***
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 Dominique d'Humieres changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2013-06-16 Ever confirmed|0 |1 --- Comment #29 from Dominique d'Humieres --- AFAICT the only remaining issue is the test in comment #22 print "(RU,F7.0)", 7500.0 ! 8. expected 7500. print "(RD,F7.0)", -7500.0 ! -8. expected -7500. which gives 7501. -7501. with 4.6 and 8. -8. with 4.7 and above.
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #28 from Jerry DeLisle 2011-07-04 14:27:06 UTC --- (In reply to comment #26) > Created attachment 24583 [details] > More tests for rounding > > If it helps, I added some more tests for this. > > By removing the code lines in questions, all tests from this testcase pass > except: > call checkfmt("(RU,F2.0)", 0.09, "1.") ! 0. > call checkfmt("(RD,F3.0)", -0.09, "-1.") ! -0. I have this issue fixed now. What is happening is that the digit string for theses cases comes in as "09xx" or "08x". Its not normalized in the usual way (why?), so the leading zero in the string is throwing off the rounding logic. [aside: I think we would be better off with our own float to decimal string routine about now] Using this: if (d == 0 && p == 0 && digits[0] == '0') { nbefore = 1; nafter = 0; } in my current trunk (which has some other modifications in it) resolves this problem for: print "(RU,F2.0)", 0.09 ! "1." print "(RD,F3.0)", -0.09 ! "-1." print "(RU,F2.0)", 0.009 ! "1." print "(RD,F3.0)", -0.009 ! "-1." print "(RU,F2.0)", 0.0009 ! "1." print "(RD,F3.0)", -0.0009 ! "-1." print "(RU,F2.0)", 0.9 ! "1." print "(RD,F3.0)", -0.9 ! "-1." Which exhibit the issue. All regression tests pass. I have not tried this on the current unfettered trunk yet and I am working on the p scaling issues.
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #27 from Jerry DeLisle 2011-06-27 23:27:23 UTC --- Status: I have not disappeared. I have a couple of other small projects to get out of the way. I did find a bit of a conflict in our code. Two snippets that were canceling each other out. I have that fixed so this one is narrowing down I think.
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #26 from Thomas Henlich 2011-06-23 06:13:12 UTC --- Created attachment 24583 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24583 More tests for rounding If it helps, I added some more tests for this. By removing the code lines in questions, all tests from this testcase pass except: call checkfmt("(RU,F2.0)", 0.09, "1.") ! 0. call checkfmt("(RD,F3.0)", -0.09, "-1.") ! -0.
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #25 from Jerry DeLisle 2011-06-21 02:51:14 UTC --- yes I already found that. Just something stupid I did for one of the test cases now in round_3.f90. I will be fixing this in due time. It's what I get when I try to do things in a hurry. (being a volunteer and having a life if you know what I mean ;) )
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #24 from Thomas Henlich 2011-06-20 07:15:19 UTC --- (In reply to comment #22) > This is kind of bad: > > print "(RU,F7.0)", 7500.0 ! 8. expected 7500. > print "(RD,F7.0)", -7500.0 ! -8. expected -7500. I've traced the bug down to this code: http://gcc.gnu.org/viewcvs/trunk/libgfortran/io/write_float.def?r1=173231&r2=173408&pathrev=173408 + rchar = '0'; + if (w > 0 && d == 0 && p == 0) +nbefore = 1; + /* Scan for trailing zeros to see if we really need to round it. */ which I don't understand. Why are we setting the number of digits before the decimal point to 1 if the width is zero and the scale factor is zero and the number of requested digits after the decimal point is zero?
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #23 from Dominique d'Humieres 2011-06-17 13:32:33 UTC --- For 'gcc version 4.6.0 20110313 (experimental) [trunk revision 170921p5] (GCC)' I get 7501. -7501.
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #22 from Thomas Henlich 2011-06-17 13:22:42 UTC --- This is kind of bad: print "(RU,F7.0)", 7500.0 ! 8. expected 7500. print "(RD,F7.0)", -7500.0 ! -8. expected -7500.
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #21 from Jerry DeLisle 2011-05-06 20:07:39 UTC --- Fixed on trunk, holding for backport
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #19 from Jerry DeLisle 2011-05-05 01:19:33 UTC --- Author: jvdelisle Date: Thu May 5 01:19:30 2011 New Revision: 173408 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173408 Log: 2011-05-04 Jerry DeLisle PR libgfortran/48787 * io/write_float.def (output_float): Adjust up and down rounding for cases where 'd' = 0. Gather common code to one location. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/write_float.def
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #20 from Jerry DeLisle 2011-05-05 01:23:50 UTC --- Author: jvdelisle Date: Thu May 5 01:23:46 2011 New Revision: 173409 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173409 Log: 2011-05-04 Jerry DeLisle PR libgfortran/48787 gfortran.dg/round_3.f08: Add more checks to test case. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/round_3.f08
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 --- Comment #18 from Jerry DeLisle 2011-05-04 16:49:17 UTC --- Ne patch submitted to list for approval. http://gcc.gnu.org/ml/fortran/2011-05/msg00022.html
[Bug libfortran/48787] Invalid UP/DOWN rounding with F editing
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787 Jerry DeLisle changed: What|Removed |Added Summary|Invalid UP rounding with F |Invalid UP/DOWN rounding |editing |with F editing --- Comment #17 from Jerry DeLisle 2011-05-03 11:45:06 UTC --- The first part of this for DOWN side is easy: Index: write_float.def === --- write_float.def(revision 173234) +++ write_float.def(working copy) @@ -242,7 +242,13 @@ output_float (st_parameter_dt *dtp, const fnode *f if (!sign_bit) goto skip; rchar = '0'; -break; +/* Scan for trailing zeros to see if we really need to round it. */ +for(i = nbefore + nafter; i < ndigits; i++) + { +if (digits[i] != '0') + goto do_rnd; + } +goto skip; case ROUND_NEAREST: /* Round compatible unless there is a tie. A tie is a 5 with all trailing zero's. */ The last two cases with + or - .09 is more subtle. We are incorrectly forcing it to zero and not rounding at all. I am still working at that part.