To: J3 J3/21-172
From: Steve Lionel
Subject: F18/033 interp: E/EN/ES/D output exponent when w=0
Date: 2021-September-02
----------------------------------------------------------------------
NUMBER: F18/033
TITLE: E/EN/ES/D output exponent when w=0
KEYWORDS: I/O, E_format
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress
QUESTION:
Consider the following program:
integer, parameter :: DP = selected_real_kind (10,300)
integer, parameter :: QP = selected_real_kind (10,3000)
real(DP) :: A
real(QP) :: B
A = 0.12345E123_DP
write (*,'(E0.7)') A ! (1)
B = 0.12345E1234_QP
write (*,'(E0.7)') B ! (2)
end
13.7.2.1 p1(6) says:
"On output, with I, B, O, Z, D, E, EN, ES, EX, F, and G editing, the
specified value of the field width w may be zero. In such cases, the
processor selects the smallest positive actual field width that does
not result in a field filled with asterisks."
and (5) above it says:
"On output, if an exponent exceeds its specified or implied width
using the E, EN, ES, EX, D, or G edit descriptor, or the number of
characters produced exceeds the field width, the processor shall fill
the entire field of width w with asterisks. However, the processor
shall not produce asterisks if the field width is not exceeded when
optional characters are omitted."
If we then look at 13.7.2.3.3 (E and D editing), table 13.1 (Exponent
forms) says that for the Ew.d form and where the absolute value of the
exponent is greater than 99 but less than or equal to 999, the form of
the exponent omits the exponent letter.
Q1: According to the text of the standard, the exponent form for the
output at (1) must be "+123", omitting the exponent letter. Was
this intended? Isn't the whole point of w=0 to produce minimal
width but complete values? Note that the exponent letter is not an
"optional character".
Q2: What should the output at (2) be? It would seem that the standard
does not provide an interpretation that results in anything but
the whole field being filled with asterisks, since the exponent
overflows three digits, yet w=0 disallows that.
ANSWER:
A1: No, this was not intended. E0.d should behave as if it were E0.dE0
(similarly for EN and ES), where the exponent letter is present
and there are the minimum number of digits needed to represent the
exponent. There is no D0.dE0 form, however, so it needs to be a
special case in the standard.
A2: The current text provides no interpretation. The proposed change
to behave as E0.dE0 provides a reasonable interpretation.
Note that G0.d does not have this problem, as the exponent form is
specified as a "reasonable processor-dependent value ... of e".
The EX descriptor also does not have this problem.
EDITS to 18-007r1:
13.7.2.3.3 (E and D editing)
264:Table 13.1 (E and D Exponent forms)
Row 1: Add after "Ew.d": " with w > 0"
Row 3: Add after "Ew.dE0": " or E0.d"
Row 4: Add after "Dw.d": " with w > 0"
Add new Row 5:
Column 1: "D0.d"
Column 2: "any"
Column 3: "D\pmz1z2 . . . zs or E\pmz1z2 . . . zs"
13.7.2.3.4 (EN editing)
265:Table 13.2 (EN Exponent forms)
Row 1: Add after "ENw.d": " with w > 0"
Row 3: Add after "ENw.dE0": " or EN0.d"
13.7.2.3.5 (ES editing)
266:Table 13.2 (ES Exponent forms)
Row 1: Add after "ESw.d": " with w > 0"
Row 3: Add after "ESw.dE0": " or ES0.d"
SUBMITTED BY: Steve Lionel
HISTORY: 21-172 m225 F18/033 submitted
----------------------------------------------------------------------