https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93567
Bug ID: 93567 Summary: G edit descriptor uses E instead F editing in rounding mode UP Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: thenlich+gccbug at gmail dot com Target Milestone: --- G editing is supposed to use F editing when the number fits in d digits, which it does in the following example #1. But when "RU" is specified (example #2), it does not. 99.0_8 is a real number with an exact internal representation (whole number), so this is also different from example #3. #2 is clearly a bug. program test_rug print "(G8.2)", 99.0_8 ! 99. print "(RU,G8.2)", 99.0_8 ! 0.99E+02 expected 99. print "(RU,G8.2)", 99.01_8 ! 0.10E+03 end "... the method of representation in the output field depends on the magnitude of the internal value being edited. ... If the internal value is a number other than zero, let N be the decimal value that is the result of converting the internal value to d significant digits according to the input/output rounding mode and let s be the integer such that 10^(s−1) ≤ |N| < 10^s. If s < 0 or s > d, kPEw.d or kPEw.dEe editing is used for Gw.d editing or Gw.dEe editing respectively, where k is the scale factor (13.8.5). If 0 ≤ s ≤ d, the scale factor has no effect and F(w − n).(d − s),n(’b’) editing is used where b is a blank and n is 4 for Gw.d editing, e + 2 for Gw.dEe editing if e > 0, and 4 for Gw.dE0 editing." In example #2: N=99 10^1 ≤ 99 < 10^2 d = s = 2 so F editing would have to be used.