public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/35036] illegal E format descriptor produces wrong output
Date: Thu, 31 Jan 2008 04:10:00 -0000	[thread overview]
Message-ID: <20080131022457.25988.qmail@sourceware.org> (raw)
In-Reply-To: <bug-35036-15709@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from kargl at gcc dot gnu dot org  2008-01-31 02:24 -------
(In reply to comment #3)
> Subject: Re:  illegal E format descriptor produces wrong
>  output
> 
> Hi,
> 
> | ------- Comment #2 from kargl at gcc dot gnu dot org  2008-01-31 01:46
> -------
> | (In reply to comment #0)
> | > "E8.0" is an illegal format descriptor,
> | 
> | Can you cite from the Fortran 95 standard why this is illegal?
> 
> Good question :-)  Unfortunately, I don't have a Fortran 95 reference
> at hand, and so let me refer to the F77 standard:
> 
>   http://www.fortran.com/fortran/F77_std/rjcnf.html
> 
> 
> <QUOTE>
> 13.5.9.2.2 E and D Editing.
> The Ew.d, Dw.d, and Ew.dEe edit descriptors indicate that the external
> field occupies w positions, the fractional part of which consists of d
> digits, unless a scale factor greater than one is in effect, and the
> exponent part consists of e digits. The e has no effect on input. 
> 
> [. . .]
> 
> The scale factor k controls the decimal normalization (13.5.7). If -d
> < k <= 0, the output field contains exactly |k| leading zeros and d -
> |k| significant digits after the decimal point. If 0 < k < d + 2, the
> output field contains exactly k significant digits to the left of the
> decimal point and d - k + 1 significant digits to the right of the
> decimal point. Other values of k are not permitted.
> </QUOTE>
> 
> When d = 0, the only possible value for the scaling factor k is 1.
> Since "Other values of k are not permitted", you *must* use "1P"
> with d = 0, as "1PE8.0".  Q.E.D.
> 
> . . . I know this is a rather roundabout logic, and I'm not 100% sure,
> actually.  I'm curious.
> 
> Now, *if* "E8.0" is legal, what output should be generated for a value
> of 1e5 ?  "0.E5" ?

Actually, I think the 'correct' output might be 0.E6.

There is no restriction in F95 that d must be positive in Ew.d.
In 10.6.5.1, it clearly states that k = 0 at the beginning of 
execution of an input/output statement.  The wording you quote
above is (almost) identical to F95 language, so one could argue
that the -d < k <= 0 is true when d = 0 and k = 0.  Yes, it might
be a stupid interpretation, but then again the standard sometime
defies logic.

In any event, gfortran is definitely giving a bogus answer
of 0E+1, and your desired output of ******* is probably the
right thing to do.

jerry, any comments?


-- 


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


  parent reply	other threads:[~2008-01-31  2:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31  2:01 [Bug fortran/35036] New: " furue at hawaii dot edu
2008-01-31  2:25 ` [Bug fortran/35036] " pinskia at gcc dot gnu dot org
2008-01-31  3:06 ` kargl at gcc dot gnu dot org
2008-01-31  3:10 ` furue at hawaii dot edu
2008-01-31  4:10 ` kargl at gcc dot gnu dot org [this message]
2008-01-31  4:44 ` furue at hawaii dot edu
2008-01-31  5:46 ` kargl at gcc dot gnu dot org
2008-01-31  6:55 ` jvdelisle at gcc dot gnu dot org
2008-01-31  6:56 ` furue at hawaii dot edu
2008-01-31  8:17 ` jvdelisle at gcc dot gnu dot org
2008-01-31 14:10 ` burnus at gcc dot gnu dot org
2008-02-02  8:28 ` jvdelisle at gcc dot gnu dot org
2008-02-02 11:14 ` dominiq at lps dot ens dot fr
2008-02-02 19:37 ` jvdelisle at gcc dot gnu dot org
2008-02-03  0:07 ` jvdelisle at gcc dot gnu dot org
2008-02-21  2:21 ` jvdelisle at gcc dot gnu dot org
2008-02-21  2:24 ` jvdelisle at gcc dot gnu dot org
2008-02-21  2:24 ` jvdelisle at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080131022457.25988.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).