http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52608
Janne Blomqvist <jb at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-03-17 Ever Confirmed|0 |1 --- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-03-17 14:25:11 UTC --- The following patch should fix it: diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index 07437f0..6521f3c 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -180,12 +180,6 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, /* Make sure the decimal point is a '.'; depending on the locale, this might not be the case otherwise. */ digits[nbefore] = '.'; - if (digits[0] == '0' && nbefore == 1) - { - digits++; - nbefore--; - ndigits--; - } if (p != 0) { if (p > 0) @@ -229,6 +223,13 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, nafter = d; } + while (digits[0] == '0' && nbefore > 0) + { + digits++; + nbefore--; + ndigits--; + } + expchar = 0; /* If we need to do rounding ourselves, get rid of the dot by moving the fractional part. */