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/intrinsics/c99_functions.c | |
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/intrinsics/c99_functions.c')
-rw-r--r-- | libgfortran/intrinsics/c99_functions.c | 24 |
1 files changed, 12 insertions, 12 deletions
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); } } |