diff options
author | Dominique d'Humieres <dominiq@gcc.gnu.org> | 2016-03-30 22:47:45 +0200 |
---|---|---|
committer | Dominique d'Humieres <dominiq@gcc.gnu.org> | 2016-03-30 22:47:45 +0200 |
commit | e0876e21cfe901193dff636ca3a7b6456a373bc7 (patch) | |
tree | 83e4ed7f4cc6fe0a7e0a7a58ff4368d3c788b7ff /libgfortran | |
parent | c73f71b7002ed8a5cc10a0332d43c84d29c57c3a (diff) | |
download | gcc-e0876e21cfe901193dff636ca3a7b6456a373bc7.zip gcc-e0876e21cfe901193dff636ca3a7b6456a373bc7.tar.gz gcc-e0876e21cfe901193dff636ca3a7b6456a373bc7.tar.bz2 |
[multiple changes]
2016-03-30 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Dominique d'Humieres <dominiq@lps.ens.fr>
PR libgfortran/70235
* io/write_float.def: Fix PF format for negative values of the scale
factor.
2016-03-30 Dominique d'Humieres <dominiq@lps.ens.fr>
Jerry DeLisle <jvdelisle@gcc.gnu.org>
* gfortran.dg/fmt_pf.f90: New test.
From-SVN: r234600
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 7 | ||||
-rw-r--r-- | libgfortran/io/write_float.def | 26 |
2 files changed, 26 insertions, 7 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 6a742b5..688a16e 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2016-03-30 Jerry DeLisle <jvdelisle@gcc.gnu.org> + Dominique d'Humieres <dominiq@lps.ens.fr> + + PR libgfortran/70235 + * io/write_float.def: Fix PF format for negative values of the scale + factor. + 2016-03-28 Alessandro Fanfarillo <fanfarillo.gcc@gmail.com> * caf/libcaf.h: caf_stop_numeric and caf_stop_str prototype. diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index d427019..d32440f 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -184,9 +184,6 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, memmove (digits + nbefore, digits + nbefore + 1, p); digits[nbefore + p] = '.'; nbefore += p; - nafter = d - p; - if (nafter < 0) - nafter = 0; nafter = d; nzero = 0; } @@ -204,12 +201,27 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size, { nzero = -(nbefore + p); memmove (digits + 1, digits, nbefore); - digits++; - nafter = d + nbefore; + nafter = d - nzero; + if (nafter == 0 && d > 0) + { + /* This is needed to get the correct rounding. */ + memmove (digits + 1, digits, ndigits - 1); + digits[1] = '0'; + nafter = 1; + nzero = d - 1; + } + else if (nafter < 0) + { + /* Reset digits to 0 in order to get correct rounding + towards infinity. */ + for (i = 0; i < ndigits; i++) + digits[i] = '0'; + digits[ndigits - 1] = '1'; + nafter = d; + nzero = 0; + } nbefore = 0; } - if (nzero > d) - nzero = d; } } else |