* mingwex/math/nexttoward.c: New file.

* mingwex/math/nexttowardf.c: New file.
	* mingwex/math/nextafterl.c: Add nexttowardl aliaa.
	* mingwex/Makefile.in (MATH_DISTFILES): Add nexttoward.c,
	mexttowardf.c,
	(MATH_OBJS):  Add nexttoward.o,	mexttowardf.o,
	* include/math.h (nexttoward, nextowardf, nexttowardl): Add
	prototypes.
This commit is contained in:
Danny Smith 2005-05-10 08:39:07 +00:00
parent 5b91f0a6ef
commit 96c837f0ca
6 changed files with 103 additions and 3 deletions

View File

@ -1,3 +1,14 @@
2005-05-10 Danny Smith <dannysmith@users.sourceforge.net>
* mingwex/math/nexttoward.c: New file.
* mingwex/math/nexttowardf.c: New file.
* mingwex/math/nextafterl.c: Add nexttowardl aliaa.
* mingwex/Makefile.in (MATH_DISTFILES): Add nexttoward.c,
mexttowardf.c,
(MATH_OBJS): Add nexttoward.o, mexttowardf.o,
* include/math.h (nexttoward, nextowardf, nexttowardl): Add
prototypes.
2005-05-09 Danny Smith <dannysmith@users.sourceforge.net>
* mingwex/math/nextafterf.c (nextafterf): Correct

View File

@ -723,7 +723,10 @@ extern double __cdecl nextafter (double, double); /* in libmoldname.a */
extern float __cdecl nextafterf (float, float);
extern long double __cdecl nextafterl (long double, long double);
/* 7.12.11.4 The nexttoward functions: TODO */
/* 7.12.11.4 The nexttoward functions */
extern double __cdecl nexttoward (double, long double);
extern float __cdecl nexttowardf (float, long double);
extern long double __cdecl nexttowardl (long double, long double);
/* 7.12.12.1 */
/* x > y ? (x - y) : 0.0 */

View File

@ -54,7 +54,8 @@ MATH_DISTFILES = \
log10f.S log10l.S log1p.S log1pf.S log1pl.S log2.S log2f.S \
log2l.S logb.c logbf.c logbl.c logf.S logl.S lrint.c lrintf.c \
lrintl.c lround.c lroundf.c lroundl.c modff.c modfl.c \
nearbyint.S nearbyintf.S nearbyintl.S nextafterf.c nextafterl.c \
nearbyint.S nearbyintf.S nearbyintl.S \
nextafterf.c nextafterl.c nexttowardf.c nexttoward.c \
powf.c powi.c powif.c powil.c powl.c \
remainder.S remainderf.S remainderl.S remquo.S \
remquof.S remquol.S rint.c rintf.c rintl.c round.c roundf.c \
@ -146,7 +147,8 @@ MATH_OBJS = \
log10f.o log10l.o log1p.o log1pf.o log1pl.o log2.o log2f.o \
log2l.o logb.o logbf.o logbl.o logf.o logl.o lrint.o lrintf.o \
lrintl.o lround.o lroundf.o lroundl.o modff.o modfl.o \
nearbyint.o nearbyintf.o nearbyintl.o nextafterf.o nextafterl.o \
nearbyint.o nearbyintf.o nearbyintl.o \
nextafterf.o nextafterl.o nexttowardf.o nexttoward.o \
powf.o powi.o powif.o powil.o powl.o \
remainder.o remainderf.o remainderl.o remquo.o \
remquof.o remquol.o rint.o rintf.o rintl.o round.o roundf.o \

View File

@ -59,3 +59,7 @@ nextafterl (long double x, long double y)
return u.ld;
}
/* nexttowardl is the same function with a different name. */
long double
nexttowardl (long double, long double) __attribute__ ((alias("nextafterl")));

View File

@ -0,0 +1,42 @@
/*
nexttoward.c
Contributed by Danny Smith <dannysmith@users.sourceforge.net>
No copyright claimed, absolutely no warranties.
2005-05-10
*/
#include <math.h>
double
nexttoward (double x, long double y)
{
union
{
double d;
unsigned long long ll;
} u;
long double xx = x;
if (isnan (y) || isnan (x))
return x + y;
if (xx == y)
/* nextafter (0.0, -O.0) should return -0.0. */
return y;
u.d = x;
if (x == 0.0)
{
u.ll = 1;
return y > 0.0L ? u.d : -u.d;
}
/* Non-extended encodings are lexicographically ordered,
with implicit "normal" bit. */
if (((x > 0.0) ^ (y > xx)) == 0)
u.ll++;
else
u.ll--;
return u.d;
}

View File

@ -0,0 +1,38 @@
/*
nexttowardf.c
Contributed by Danny Smith <dannysmith@users.sourceforge.net>
No copyright claimed, absolutely no warranties.
2005-05-10
*/
#include <math.h>
float
nexttowardf (float x, long double y)
{
union
{
float f;
unsigned int i;
} u;
long double xx = x;
if (isnan (y) || isnan (x))
return x + y;
if (xx == 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.0L ? u.f : -u.f;
}
if (((x > 0.0F) ^ (y > xx)) == 0)
u.i++;
else
u.i--;
return u.f;
}