------- Comment #8 from danglin at gcc dot gnu dot org  2008-12-28 20:25 -------
The value calculated for b = nearest(0.5,-1.0) is 0.49999997 (raw 0x3effffff).
The code uses the roundf implementation in c99_functions.

float
roundf(float x)
{
   float t;
   if (!isfinite (x))
     return (x);

   if (x >= 0.0) 
    {
      t = ceilf(x);
      if (t - x > 0.5)
        t -= 1.0;
      return (t);
    } 
   else 
    {
      t = ceilf(-x);
      if (t + x > 0.5)
        t -= 1.0;
      return (-t);
    }
}

The call to ceilf returns t = 1 (raw 0x3f800000).  The result of t - x
is 0.5 (raw 0x3f000000).  So, roundf returns 1 and the test fails.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33595

Reply via email to