From 0e8fc1857d7cd24c8e09e1eadcff184249fb4746 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Tue, 6 Oct 2009 03:08:20 +0000 Subject: [PATCH] re PR libfortran/35862 ([F2003] Implement new rounding modes for run time) 2009-10-05 Jerry DeLisle PR libgfortran/35862 * write_float.def (outout_float): Fix handling of special case where no digits after the decimal point and values less than 1.0. Adjust index into digits string. (WRITE_FLOAT): Remove special case code from macro. From-SVN: r152483 --- libgfortran/ChangeLog | 7 +++++++ libgfortran/io/write_float.def | 19 +++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2530bf7d3ea..014d883ffe2 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2009-10-05 Jerry DeLisle + + PR libgfortran/35862 + * write_float.def (outout_float): Fix handling of special case where no + digits after the decimal point and values less than 1.0. Adjust index + into digits string. (WRITE_FLOAT): Remove special case code from macro. + 2009-09-28 Jerry DeLisle PR libgfortran/35862 diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index e6880027a86..eca0e56a5e9 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -141,6 +141,13 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, switch (ft) { case FMT_F: + if (d == 0 && e <= 0 && dtp->u.p.scale_factor == 0) + { + memmove (digits + 1, digits, ndigits - 1); + digits[0] = '0'; + e++; + } + nbefore = e + dtp->u.p.scale_factor; if (nbefore < 0) { @@ -255,7 +262,7 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, case ROUND_NEAREST: /* Round compatible unless there is a tie. A tie is a 5 with all trailing zero's. */ - i = nafter + 1; + i = nafter + nbefore; if (digits[i] == '5') { for(i++ ; i < ndigits; i++) @@ -264,7 +271,7 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, goto do_rnd; } /* It is a tie so round to even. */ - switch (digits[nafter]) + switch (digits[nafter + nbefore - 1]) { case '1': case '3': @@ -818,14 +825,6 @@ sprintf (buffer, "%+-#" STR(MIN_FIELD_WIDTH) ".*" \ return;\ }\ tmp = sign_bit ? -tmp : tmp;\ - if (f->u.real.d == 0 && f->format == FMT_F\ - && dtp->u.p.scale_factor == 0)\ - {\ - if (tmp < 0.5)\ - tmp = 0.0;\ - else if (tmp < 1.0)\ - tmp = 1.0;\ - }\ zero_flag = (tmp == 0.0);\ \ DTOA ## y\