aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/write.c
diff options
context:
space:
mode:
authorPaul Brook <pbrook@gcc.gnu.org>2004-10-04 15:33:18 +0000
committerPaul Brook <pbrook@gcc.gnu.org>2004-10-04 15:33:18 +0000
commit06e4f02a16465f976c9f1a179fd2c60fb76e9659 (patch)
tree4114a0c97da613eea429829446e76db65fd5d026 /libgfortran/io/write.c
parentf3e41701124d2c5a838c28b99bbc4d8fd69e381e (diff)
downloadgcc-06e4f02a16465f976c9f1a179fd2c60fb76e9659.zip
gcc-06e4f02a16465f976c9f1a179fd2c60fb76e9659.tar.gz
gcc-06e4f02a16465f976c9f1a179fd2c60fb76e9659.tar.bz2
re PR libfortran/17706 (reading a value of 0.0 gives a value of -0.0)
2004-10-04 Paul Brook <paul@codesourcery.com> Bud Davis <bdavis9659@comcast.net> PR fortran/17706 PR fortran/16434 * io/format.c (parse_format_list): Set repeat count for S, SP, SS, BN and BZ formats. * io/write.c (output_float): Don't output minus zero. libgfortran/ * gfortran/pr17706.f90: New test. * gfortran.dg/g77/f77-edit-s-out.f: Remove xfail. Actually apply the patch this time. From-SVN: r88513
Diffstat (limited to 'libgfortran/io/write.c')
-rw-r--r--libgfortran/io/write.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 4e22b70..f98ec1f 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -425,9 +425,12 @@ output_float (fnode *f, double value, int len)
}
/* Round the value. */
- if (nbefore + nafter < ndigits && nbefore + nafter > 0)
+ if (nbefore + nafter == 0)
+ ndigits = 0;
+ else if (nbefore + nafter < ndigits)
{
- i = nbefore + nafter;
+ ndigits = nbefore + nafter;
+ i = ndigits;
if (digits[i] >= '5')
{
/* Propagate the carry. */
@@ -513,6 +516,16 @@ output_float (fnode *f, double value, int len)
if (out == NULL)
return;
+ /* Zero values always output as positive, even if the value was negative
+ before rounding. */
+ for (i = 0; i < ndigits; i++)
+ {
+ if (digits[i] != '0')
+ break;
+ }
+ if (i == ndigits)
+ sign = calculate_sign (0);
+
/* Work out how much padding is needed. */
nblanks = w - (nbefore + nzero + nafter + edigits + 1);
if (sign != SIGN_NONE)