diff options
author | John David Anglin <dave.anglin@nrc-cnrc.gc.ca> | 2009-03-28 21:15:45 +0000 |
---|---|---|
committer | John David Anglin <danglin@gcc.gnu.org> | 2009-03-28 21:15:45 +0000 |
commit | 63f90eb7b0a70009743f7bb0035de2c956add767 (patch) | |
tree | fc0e3a7744e96af4f2a2f3feb4f8d7766b3dc2e7 /libgfortran | |
parent | 8272d11d4aa82d07cae099cccbb2dae7ee826099 (diff) | |
download | gcc-63f90eb7b0a70009743f7bb0035de2c956add767.zip gcc-63f90eb7b0a70009743f7bb0035de2c956add767.tar.gz gcc-63f90eb7b0a70009743f7bb0035de2c956add767.tar.bz2 |
re PR libfortran/33595 (FAIL: gfortran.dg/nint_2.f90 -O0 execution test)
PR fortran/33595
* intrinsics/c99_functions.c (round): Use floor instead of ceil.
Revise checks to round up.
(roundf): Likewise.
From-SVN: r145209
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 7 | ||||
-rw-r--r-- | libgfortran/intrinsics/c99_functions.c | 24 |
2 files changed, 19 insertions, 12 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 45779d6..e0ec250 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2009-03-29 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> + + PR fortran/33595 + * intrinsics/c99_functions.c (round): Use floor instead of ceil. + Revise checks to round up. + (roundf): Likewise. + 2009-03-28 Daniel Kraft <d@domob.eu> * intrinsics/string_intrinsics.c: #include <assert.h> diff --git a/libgfortran/intrinsics/c99_functions.c b/libgfortran/intrinsics/c99_functions.c index ce96c8c..66f06b3 100644 --- a/libgfortran/intrinsics/c99_functions.c +++ b/libgfortran/intrinsics/c99_functions.c @@ -571,16 +571,16 @@ round(double x) if (x >= 0.0) { - t = ceil(x); - if (t - x > 0.5) - t -= 1.0; + t = floor(x); + if (t - x <= -0.5) + t += 1.0; return (t); } else { - t = ceil(-x); - if (t + x > 0.5) - t -= 1.0; + t = floor(-x); + if (t + x <= -0.5) + t += 1.0; return (-t); } } @@ -600,16 +600,16 @@ roundf(float x) if (x >= 0.0) { - t = ceilf(x); - if (t - x > 0.5) - t -= 1.0; + t = floorf(x); + if (t - x <= -0.5) + t += 1.0; return (t); } else { - t = ceilf(-x); - if (t + x > 0.5) - t -= 1.0; + t = floorf(-x); + if (t + x <= -0.5) + t += 1.0; return (-t); } } |