From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27292 invoked by alias); 20 Jun 2011 07:15:40 -0000 Received: (qmail 27283 invoked by uid 22791); 20 Jun 2011 07:15:39 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Mon, 20 Jun 2011 07:15:25 +0000 From: "thenlich at users dot sourceforge.net" 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: thenlich at users dot sourceforge.net 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: 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: Mon, 20 Jun 2011 07:15: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-06/txt/msg01723.txt.bz2 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?