public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/47567] New: Wrong output for small absolute values with F editing
@ 2011-02-01  9:42 thenlich at users dot sourceforge.net
  2011-02-01 11:27 ` [Bug libfortran/47567] " burnus at gcc dot gnu.org
                   ` (31 more replies)
  0 siblings, 32 replies; 33+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-02-01  9:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47567

           Summary: Wrong output for small absolute values with F editing
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: thenlich@users.sourceforge.net


Fortran 2008, 10.7.2.3.2(9):
For an internal value that is neither an IEEE infinity nor a NaN, the output
field consists of blanks, if necessary, followed by a minus sign if the
internal value is negative, or an optional plus sign otherwise, followed by a
string of digits that contains a decimal symbol and represents the magnitude of
the internal value, as modified by the established scale factor and rounded
(10.7.2.3.7) to d fractional digits. Leading zeros are not permitted except
for an optional zero immediately to the left of the decimal symbol if the
magnitude of the value in the output field is less than one. The optional zero
shall appear if there would otherwise be no digits in the output field.

In gfortran, with an (F0.0) edit descriptor, some small values are formatted as
".", e.g.

    print "(F0.0)", 0.0   ! => 0.
    print "(F0.0)", 0.001 ! => . expected 0.
    print "(F0.0)", 0.01  ! => . expected 0.
    print "(F0.0)", 0.1   ! => 0.

Reason: "The optional zero shall appear if there would otherwise be no digits
in the output field."

Any formatting of non-negative values with (F1.n) should always result in
asterisks, because "a string of digits that contains a decimal symbol", where
"the optional zero shall appear if there would otherwise be no digits in the
output field" can never fit in 1. E. g.

    print "(F1.0)", 0.0   ! => 0 expected *
    print "(F1.0)", 0.001 ! => . expected *
    print "(F1.0)", 0.01  ! => . expected *
    print "(F1.0)", 0.1   ! => *

Similarly, for negative values and (F2.n):

    print "(F2.0)", -0.001 ! => -. expected **
    print "(F2.0)", -0.01  ! => -. expected **
    print "(F2.0)", -0.1   ! => **

The exact value "0.0" is formatted with a leading zero with (F0.n) formatting,
but this is incorrect, see bug 47434:

    print "(F0.2)", 0.0   ! => 0.00 expected .00


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2011-03-02 14:01 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01  9:42 [Bug libfortran/47567] New: Wrong output for small absolute values with F editing thenlich at users dot sourceforge.net
2011-02-01 11:27 ` [Bug libfortran/47567] " burnus at gcc dot gnu.org
2011-02-01 13:48 ` jvdelisle at gcc dot gnu.org
2011-02-05  1:33 ` jvdelisle at gcc dot gnu.org
2011-02-05  2:10 ` jvdelisle at gcc dot gnu.org
2011-02-05  6:22 ` jvdelisle at gcc dot gnu.org
2011-02-05  7:41 ` thenlich at users dot sourceforge.net
2011-02-05  7:46 ` thenlich at users dot sourceforge.net
2011-02-05  7:53 ` thenlich at users dot sourceforge.net
2011-02-05 13:15 ` jvdelisle at gcc dot gnu.org
2011-02-05 17:59 ` jvdelisle at gcc dot gnu.org
2011-02-06 22:15 ` jvdelisle at gcc dot gnu.org
2011-02-07  8:21 ` thenlich at users dot sourceforge.net
2011-02-08  7:17 ` thenlich at users dot sourceforge.net
2011-02-08 12:40 ` jvdelisle at gcc dot gnu.org
2011-02-17  6:51 ` jvdelisle at gcc dot gnu.org
2011-02-17 19:40 ` jvdelisle at gcc dot gnu.org
2011-02-19 15:20 ` jvdelisle at gcc dot gnu.org
2011-02-19 15:36 ` jvdelisle at gcc dot gnu.org
2011-02-19 15:53 ` jvdelisle at gcc dot gnu.org
2011-02-21 13:42 ` thenlich at users dot sourceforge.net
2011-02-21 14:30 ` jvdelisle at gcc dot gnu.org
2011-02-21 14:33 ` jvdelisle at gcc dot gnu.org
2011-02-24  5:32 ` jvdelisle at gcc dot gnu.org
2011-02-24  5:33 ` jvdelisle at gcc dot gnu.org
2011-02-24  6:59 ` jvdelisle at gcc dot gnu.org
2011-02-25 14:05 ` thenlich at users dot sourceforge.net
2011-02-25 14:08 ` thenlich at users dot sourceforge.net
2011-02-28 21:41 ` jvdelisle at gcc dot gnu.org
2011-03-01  2:25 ` jvdelisle at gcc dot gnu.org
2011-03-01  2:28 ` jvdelisle at gcc dot gnu.org
2011-03-01  2:30 ` jvdelisle at gcc dot gnu.org
2011-03-02 14:01 ` thenlich at users dot sourceforge.net

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).