This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bug report : gfortran E edit descriptor

I think gfortran's result *is* *correct* according to the
Fortran standard.

(I concur that the result is not what one would expect but
it is now decades to late to change that.)

sudo.michio wrote:
> I have an trouble in E edit descriptor of gfortran.
> This is a example.
>       write(*,'(e9.3,a,f7.1)')a,' ',b
>       write(*,'(1pe9.3,a,f7.1)')a,' ',b
> (execute)
> a.exe
> (result)
>   135.000000       1737.50000    
> 0.135E+03  1737.5
> 1.350E+02 17375.0  ( <--- wrong value )

Looking at the Fortran standard [1], the result looks

"The k P edit descriptor temporarily changes (9.5.2) the scale
 factor for the connection to k. The scale factor affects the
 editing done by the F, E, EN, ES, D, and G edit descriptors
 for numeric quantities.

 * On output, with F output editing, the effect is that the
   externally represented number equals the internally represented
   number multiplied by 10**k; the internal value is converted using
   the I/O rounding mode and then the scale factor is applied to
   the converted decimal value.

 * On output, with E and D editing, the effect is that the
   significand (R414) part of the quantity to be produced is
   multiplied by 10**k and the exponent is reduced by k."

The referenced 9.5.2 contains the following, which implies
that the "1p" not only affects the immediately following "e9.3"
but also the later "f7.1":

"Edit descriptors take effect when they are encountered in
 format processing.  When a data transfer statement terminates,
 the values for the modes are reset to the values in effect
 immediately before the data transfer statement was executed."



Section "10.8.5 P editing"
Page 279 of the document, page number labelled as "261"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]