From: John David Anglin Date: Sun, 17 Oct 2010 00:29:12 +0000 (+0000) Subject: backport: re PR libfortran/33595 (FAIL: gfortran.dg/nint_2.f90 -O0 execution test) X-Git-Tag: releases/gcc-4.4.6~310 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a49c438e8468eaff3ac220dac817af68df18e818;p=thirdparty%2Fgcc.git backport: re PR libfortran/33595 (FAIL: gfortran.dg/nint_2.f90 -O0 execution test) Backport from mainline 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. From-SVN: r165574 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 031bc7ae5a3f..100645678f28 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,13 @@ +2010-10-16 John David Anglin + + Backport from mainline: + 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. + 2010-10-06 Jerry DeLisle Backport from mainline: diff --git a/libgfortran/intrinsics/c99_functions.c b/libgfortran/intrinsics/c99_functions.c index 9b3170234208..d4ed17fc1b00 100644 --- a/libgfortran/intrinsics/c99_functions.c +++ b/libgfortran/intrinsics/c99_functions.c @@ -566,16 +566,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); } } @@ -595,16 +595,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); } }