From cbab2ab2719efc1858b9361e76b52f6359119c8f Mon Sep 17 00:00:00 2001 From: John Marino Date: Thu, 16 Jul 2015 01:11:04 +0200 Subject: [PATCH] OpenLIBM: Try to fix nextafterl My first attempt at fixing this function to deal with the always-true > 0 condition was a mistake. The problem was that esy and esy were typed as u_int32_t when they should have been "int" according to math_private.h. This still doesn't fix the rounding error in Fortran so it's possible this function is still broken (upstream too). The FreeBSD version is a bit different. --- contrib/openbsd_libm/src/ld80/s_nextafterl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/openbsd_libm/src/ld80/s_nextafterl.c b/contrib/openbsd_libm/src/ld80/s_nextafterl.c index 39095c28ea..977c6f4d6d 100644 --- a/contrib/openbsd_libm/src/ld80/s_nextafterl.c +++ b/contrib/openbsd_libm/src/ld80/s_nextafterl.c @@ -26,7 +26,8 @@ long double nextafterl(long double x, long double y) { int32_t hx,hy,ix,iy; - u_int32_t lx,ly,esx,esy; + u_int32_t lx,ly; + int esx,esy; GET_LDOUBLE_WORDS(esx,hx,lx,x); GET_LDOUBLE_WORDS(esy,hy,ly,y); @@ -60,7 +61,7 @@ nextafterl(long double x, long double y) } } } else { /* x < 0 */ - if(/*esy>=0||*/(ix>iy||((ix==iy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){ + if(esy>=0||(ix>iy||((ix==iy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){ /* x < y, x -= ulp */ if(lx==0) { if ((hx&0x7fffffff)==0) esx -= 1; -- 2.41.0