]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>
Fri, 11 Mar 2005 08:03:02 +0000 (09:03 +0100)
committerBud Davis <bdavis@gcc.gnu.org>
Fri, 11 Mar 2005 08:03:02 +0000 (08:03 +0000)
2005-03-12  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

        PR libfortran/20124
        * gfortran.dg/pr20124.f90: New Test

2005-03-11  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

        PR libfortran/20124
        * write.c (output_float): Adds a nzero_real variable to store
        the number of leading zeros whatever the format width is. Corrects
        the rounding of numbers less than 10^(-width). Fixes typo in an
        error message. Updates copyright years

From-SVN: r96291

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr20124.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/write.c

index c51d1d111063674434e5dd226d76da4eff85cbd2..109c8482ca81d1b176916cd9f0a06dc258618598 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-12  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR libfortran/20124
+       * gfortran.dg/pr20124.f90: New Test
+
 2005-03-10  James A. Morrison  <phython@gcc.gnu.org>
 
        PR tree-optimization/20130
diff --git a/gcc/testsuite/gfortran.dg/pr20124.f90 b/gcc/testsuite/gfortran.dg/pr20124.f90
new file mode 100644 (file)
index 0000000..69f4f18
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do run }
+! pr 20124
+      character*80 line
+      x = -.01
+      y = .01
+      write(line,'(2f10.2)') x, y
+      if (line.ne.'     -0.01      0.01') call abort
+      end
index 2e3bd391b407dbcbab0da35a60d4929f7bb794b3..ac7e067e5c901ac66abcbbcacd498b93375efa54 100644 (file)
@@ -1,3 +1,11 @@
+2005-03-11  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR libfortran/20124
+       * write.c (output_float): Adds a nzero_real variable to store
+       the number of leading zeros whatever the format width is. Corrects
+       the rounding of numbers less than 10^(-width). Fixes typo in an
+       error message. Updates copyright years
+
 2005-02-27  Toon Moene  <toon@moene.indiv.nluug.nl>
 
        * runtime/environ.c: Update copyright years.
index 1babd20463f07f70eaa58fc89504b44bb3bc4fc2..9c255d7d69ee47a5e6e27f0e18fb2fdf435e6018 100644 (file)
@@ -286,6 +286,8 @@ output_float (fnode *f, double value, int len)
   int nzero;
   /* Number of digits after the decimal point.  */
   int nafter;
+  /* Number of zeros after the decimal point, whatever the precision.  */
+  int nzero_real;
   int leadzero;
   int nblanks;
   int i;
@@ -295,6 +297,9 @@ output_float (fnode *f, double value, int len)
   w = f->u.real.w;
   d = f->u.real.d;
 
+  nzero_real = -1;
+
+
   /* We should always know the field width and precision.  */
   if (d < 0)
     internal_error ("Unspecified precision");
@@ -359,6 +364,7 @@ output_float (fnode *f, double value, int len)
       if (nbefore < 0)
        {
          nzero = -nbefore;
+          nzero_real = nzero;
          if (nzero > d)
            nzero = d;
          nafter = d - nzero;
@@ -436,7 +442,17 @@ output_float (fnode *f, double value, int len)
 
   /* Round the value.  */
   if (nbefore + nafter == 0)
-    ndigits = 0;
+    {
+      ndigits = 0;
+      if (nzero_real == d && digits[0] >= '5')
+        {
+          /* We rounded to zero but shouldn't have */
+          nzero--;
+          nafter = 1;
+          digits[0] = '1';
+          ndigits = 1;
+        }
+    }
   else if (nbefore + nafter < ndigits)
     {
       ndigits = nbefore + nafter;