2002-07-29 11:00:10 +08:00
|
|
|
#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 )
|
2005-05-09 17:36:10 +08:00
|
|
|
/* nextafter (0.0, -O.0) should return -0.0. */
|
|
|
|
return y;
|
2002-07-29 11:00:10 +08:00
|
|
|
u.f = x;
|
2005-05-09 17:36:10 +08:00
|
|
|
if (x == 0.0F)
|
2002-07-29 11:00:10 +08:00
|
|
|
{
|
2005-05-09 17:36:10 +08:00
|
|
|
u.i = 1;
|
|
|
|
return y > 0.0F ? u.f : -u.f;
|
2002-07-29 11:00:10 +08:00
|
|
|
}
|
2005-05-09 17:36:10 +08:00
|
|
|
if (((x > 0.0F) ^ (y > x)) == 0)
|
2002-07-29 11:00:10 +08:00
|
|
|
u.i++;
|
|
|
|
else
|
|
|
|
u.i--;
|
|
|
|
return u.f;
|
|
|
|
}
|