11-174r2
To: J3
From: John Reid and Thomas Henlich and Malcolm Cohen
Subject: Interp: G editing for reals
Date: 2011 June 30
---------------------------------------------------------------------
NUMBER: F08/0055
TITLE: G editing for reals
KEYWORDS: format, G editing
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress
QUESTION:
Q1. Gw.d editing for a real value that is in the range (0.1,10**d) and
is not near an integer power of 10 uses F editing to produce
exactly a value with d significant digits. For values in this
range that are near an integer power of 10, is it intended that F
editing be used to produce a value with d significant digits?
The rules in 10.7.5.2.2 usually have this effect, but the following
examples illustrate exceptions for rounding UP and to ZERO.
print "(ru,g11.2)", -9.95
print "(rz,g11.2)", -9.95
When rounded to two significant digits these are both equal to -9.9,
however following through the rules in the standard it says to use
F7.0 format which will give the result -9. (only one significant
digit). For positive values, rounding DOWN and to ZERO
print "(rd,g11.2)", 9.95
print "(rz,g11.2)", 9.95
both give the result 9.9 according to the rules in the standard.
Q2. Is Gw.d editing intended to use F editing when that produces d
significant digits?
It usually achieves this, but for
print "(ru,0p,g11.2)", -99.5
the standard requires 0PE11.2 editing to be used, which gives
-0.99E+02
even though F7.2 editing can represent it as -99.
Similarly for
print "(ru,0p,g11.2)", 99.
the standard requires 0PE11.2 editing to be used, which gives
0.99E+02, even though it is representable in F7.2 format as 99.
Q3. COMPATIBLE and NEAREST modes of rounding differ only when the two
nearest representable values are equidistant from the given
value. The similarity appears not to be represented in the second
table. What is meant by "if the higher value is even"?
If by "even" we mean the last digit is even, then since we are talking
about a mantissa which is close to 10, COMPATIBLE and NEAREST would
have the same effect.
Q4. The table has no entry for PROCESSOR_DEFINED rounding; since there
is no value specified for r, it is impossible to interpret the
table, which seems to indicate that it would not be standard
conforming to use G editing with PROCESSOR_DEFINED. How does the
PROCESSOR_DEFINED I/O rounding mode affect G editing?
Q5. According to 10.7.2.3.7 paragraphs 3 and 4, the effect of NEAREST
is processor dependent unless IEEE rounding on conversions is
supported. How does this affect G editing?
Q6. Consider
PRINT '(5(1X,1PG9.0))', 0.0, 0.04, 0.06, 0.4, 0.6
noting that these values are strictly monotonic increasing.
The standard appears to say that the output should be
0.E+00 4.E-02 0. 0. 6.E-01
which is decidedly not monotonic increasing.
Is this intentional?
ANSWER:
A1. Yes, it is intended to produce output with d significant digits.
The algorithm for choosing the output form for some I/O rounding
modes is defective. An edit is provided to replace this
algorithm.
A2. Yes. This is solved by the same edit.
A3. This question is rendered moot by the same edit.
A4. This question is rendered moot by the same edit.
A5. This question is rendered moot by the same edit.
A6. No. An edit is supplied to fix this.
EDITS to 10-007r1:
[24:11+] In 1.6.2, insert new paragraph following paragraph 1:
"The form produced by the G edit descriptor for some values and some
I/O rounding modes differs from that specified by Fortran 2003."
[24:27+] In 1.6.3, append new bullet item
"- The form produced by the G edit descriptor with d==0 differs from
that specified by Fortran 95 for some values.".
[25:6] In 1.6.4, replace the last full stop with semicolon and insert
new bullet item
"- the G edit descriptor with d==0 for some values.".
[258:14-]
Insert new paragraph
"If \si{d} is zero, \si{k}PE\si{w}.0 or \si{k}PE\si{w}.0E\si{e}
editing is used for G\si{w}.0 editing or G\si{w}.0E\si{e} editing
respectively."
{Without the italics markup, this is
"If d is zero, kPEw.0 or kPEw.0Ee editing is used for Gw.0 editing
or Gw.0Ee editing respectively."}
[258:15-19]
Replace the second and subsequent sentences of paragraph 4 including
the two internal pseudo-tables by
"Let \it{N} be the decimal value resulting from the conversion of
the internal value to decimal and its subsequent rounding to \si{d}
significant digits according to the I/O rounding mode, and let
\it{s} be the decimal exponent value of \it{N}, or 1 if \it{N} is
equal to zero. If 0<=\it{s}<=\si{d},
F(\si{w}-\it{n}).(\si{d}-\it{s}),n('b') editing is used where \it{b}
is a blank and \it{n} is 4 for G\si{w}.\si{d} editing and \si{e}+2
for G\si{w}.\si{d}E\si{e} editing. If \it{s}<0 or \it{s}>d,
\si{k}PE\si{w}.\si{d} or \si{k}PE\si{w}.\si{d}E\si{e} editing is
used for G\si{w}.\si{d} editing or G\si{w}.\si{d}E\si{e} editing
respectively."
{Note: \it{something} is something in italics,
\si{something} is a syntax term (in italics).
Without the italics markup, this is
"Let N be the decimal value resulting from the conversion of the
internal value to decimal and its subsequent rounding to d
significant digits according to the I/O rounding mode, and let
s be the decimal exponent value of N, or 1 if N is equal to zero.
If 0<=s<=d, F(w-n).(d-s),n('b') editing is used where b is a blank
and n is 4 for Gw.d editing and e+2 for Gw.dEe editing. If s<0 or
s>d, kPEw.d or kPEw.dEe editing is used for Gw.d editing or Gw.dEe
editing respectively."}
SUBMITTED BY: John Reid and Thomas Henlich
HISTORY: 11-174 m195 Submitted
11-174r2 Revised answer.
------------------------------------------------------------------------