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