From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26496 invoked by alias); 3 May 2011 11:47:59 -0000 Received: (qmail 26483 invoked by uid 22791); 3 May 2011 11:47:59 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_JV X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 May 2011 11:47:45 +0000 From: "jvdelisle at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/48787] Invalid UP/DOWN rounding with F editing X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: jvdelisle at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jvdelisle at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Summary Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 03 May 2011 11:47:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00182.txt.bz2 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.