------- Comment #13 from kargl at gcc dot gnu dot org 2008-12-28 22:14 ------- (In reply to comment #12) > Subject: Re: FAIL: gfortran.dg/nint_2.f90 -O0 execution test > > > See libm on FreeBSD. > > > > http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/msun/src/s_roundf.c > > So, the ceilf implementation was changed to a floorf implementation > to correct rounding issues about three years ago... > > I'll give it a try. The default rounding mode on hpux is nearest. >
It also uses your idea or something very similar. Notice the changes in the if-statements. 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); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33595