From 63f90eb7b0a70009743f7bb0035de2c956add767 Mon Sep 17 00:00:00 2001 From: John David Anglin Date: Sat, 28 Mar 2009 21:15:45 +0000 Subject: 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 --- libgfortran/ChangeLog | 7 +++++++ libgfortran/intrinsics/c99_functions.c | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'libgfortran') 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 + + 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 * intrinsics/string_intrinsics.c: #include 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); } } -- cgit v1.1