This is the mail archive of the
mailing list for the GCC project.
Re: bug report : gfortran E edit descriptor
- From: Tobias Burnus <tobias dot burnus at physik dot fu-berlin dot de>
- To: "sudo.michio" <sudo dot michio at jaea dot go dot jp>, gcc at gcc dot gnu dot org
- Date: Thu, 10 Mar 2016 11:14:39 +0100
- Subject: Re: bug report : gfortran E edit descriptor
- Authentication-results: sourceware.org; auth=none
I think gfortran's result *is* *correct* according to the
(I concur that the result is not what one would expect but
it is now decades to late to change that.)
> 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
> 135.000000 1737.50000
> 0.135E+03 1737.5
> 1.350E+02 17375.0 ( <--- wrong value )
Looking at the Fortran standard , 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"