newlib/winsup/mingw/mingwex/math/nextafterf.c
Danny Smith 5b91f0a6ef * mingwex/math/nextafterf.c (nextafterf): Correct
handling of -0.0.
	* mingwex/math/nextafterl.c: New file.
	* mingwex/Makefile.in (MATH_DISTFILES): Add nextafterl.c.
	(MATH_OBJS): Add nextafterl.o.
	* include/math.h (nextafterl): Uncomment prototype.
2005-05-09 09:36:10 +00:00

28 lines
413 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;
}