diff options
author | Danny Smith <dannysmith@users.sourceforge.net> | 2005-05-10 12:39:07 +0400 |
---|---|---|
committer | Danny Smith <dannysmith@users.sourceforge.net> | 2005-05-10 12:39:07 +0400 |
commit | 96c837f0ca50aa9e625fdbc5fb9ba088fc99405d (patch) | |
tree | 4a4945bfbfc3135bbb9cc10a8050eb9bb085891e /winsup/mingw/mingwex | |
parent | 5b91f0a6efc120a2c7b26000347f4a2876577fa8 (diff) |
* 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.
Diffstat (limited to 'winsup/mingw/mingwex')
-rw-r--r-- | winsup/mingw/mingwex/Makefile.in | 6 | ||||
-rwxr-xr-x | winsup/mingw/mingwex/math/nextafterl.c | 4 | ||||
-rwxr-xr-x | winsup/mingw/mingwex/math/nexttoward.c | 42 | ||||
-rwxr-xr-x | winsup/mingw/mingwex/math/nexttowardf.c | 38 |
4 files changed, 88 insertions, 2 deletions
diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in index 289a44c54..feb9bd670 100644 --- a/winsup/mingw/mingwex/Makefile.in +++ b/winsup/mingw/mingwex/Makefile.in @@ -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 \ diff --git a/winsup/mingw/mingwex/math/nextafterl.c b/winsup/mingw/mingwex/math/nextafterl.c index 84be44fb2..eaf6a3f03 100755 --- a/winsup/mingw/mingwex/math/nextafterl.c +++ b/winsup/mingw/mingwex/math/nextafterl.c @@ -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"))); diff --git a/winsup/mingw/mingwex/math/nexttoward.c b/winsup/mingw/mingwex/math/nexttoward.c new file mode 100755 index 000000000..6a4c820f2 --- /dev/null +++ b/winsup/mingw/mingwex/math/nexttoward.c @@ -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; +} diff --git a/winsup/mingw/mingwex/math/nexttowardf.c b/winsup/mingw/mingwex/math/nexttowardf.c new file mode 100755 index 000000000..80ac1a357 --- /dev/null +++ b/winsup/mingw/mingwex/math/nexttowardf.c @@ -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; +} |