2006-08-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Aug 2006 05:14:05 +0000 (05:14 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Aug 2006 05:14:05 +0000 (05:14 +0000)
PR libgfortran/28354
* io/write.c: Check for special case of zero precision in format
and pre-round the real value.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116502 138bc75d-0d04-0410-961f-82ee72b054a4

libgfortran/ChangeLog
libgfortran/io/write.c

index 773f806..7151344 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libgfortran/28354
+       * io/write.c: Check for special case of zero precision in format
+       and pre-round the real value.
+
 2006-08-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/25828
index bee367c..79018cc 100644 (file)
@@ -426,6 +426,15 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value)
   if (value < 0)
     value = -value;
 
+  /* Special case when format specifies no digits after the decimal point.  */
+  if (d == 0)
+    {
+      if (value < 0.5)
+       value = 0.0;
+      else if (value < 1.0)
+       value = value + 0.5;
+    }
+
   /* Printf always prints at least two exponent digits.  */
   if (value == 0)
     edigits = 2;