[Bug libfortran/48602] Invalid F conversion of G descriptor for values close to powers of 10
thenlich at users dot sourceforge.net
gcc-bugzilla@gcc.gnu.org
Fri Apr 15 20:01:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48602
--- Comment #3 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-04-15 19:58:55 UTC ---
(In reply to comment #2)
> I am missing something here:
>
> "print "(RU,G15.2)", .991d0
> prints 1.00 but the expected result is 1.0 because 1 - r * 10**-2 < .991 with r
> = 1 because of UP rounding mode"
>
> We are asking for two decimal digits in g15.2 above so 1.00 looks right to me.
No. The d in G editing describes the number of significant digits, not the
number of decimal digits.
Fortran 2008: 10.7.5.2.2 states clearly (first table in clause 4) that for a
value which rounds to a value greater or equal to 1 and smaller than 10 the
equivalent conversion is F(w-n).(d-1) and n blanks.
Thus the number of significant digits is d, because 1 digit comes before the
decimal separator and (d-1) digits after it.
GFortran does it right in most cases, except the ones described in this bug:
UP/DOWN rounding with values close to 1 (or other powers of 10) which would
round differently if COMPATIBLE rounding was in effect.
More information about the Gcc-bugs
mailing list