kolibrios/programs/develop/libraries/newlib/math/nextafterf.c
Sergey Semyonov (Serge) 2336060a0c newlib: update
git-svn-id: svn://kolibrios.org@1906 a494cfbc-eb01-0410-851d-a64ba20cac60
2011-03-11 18:52:24 +00:00

28 lines
440 B
C

#include <math.h>
float
nextafterf (float x, float y)
{
union
{
float f;
unsigned int i;
} u;
if (isnan (y) || isnan (x))
return x + y;
if (x == y )
/* nextafter (0.0, -O.0) should return -0.0. */
return y;
u.f = x;
if (x == 0.0F)
{
u.i = 1;
return y > 0.0F ? u.f : -u.f;
}
if (((x > 0.0F) ^ (y > x)) == 0)
u.i++;
else
u.i--;
return u.f;
}