http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48787
--- Comment #28 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 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 "0900000000xxxxxx" or "0899999999xxxxx". 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.00009 ! "1." print "(RD,F3.0)", -0.00009 ! "-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.