summaryrefslogtreecommitdiff
path: root/lib/libm
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2015-07-19 17:31:48 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2015-07-19 17:31:48 +0000
commit79ce53f5422c7e39f8f500a10144fcf8aa7d8e20 (patch)
treea2f90105800e1b047aa2c28fbc97616679b8910f /lib/libm
parent549ffe9ae930306ab0a5d36a3848fdde34bad33e (diff)
Make exponents of x and y signed and fix esx and esy
comparisons. The offending input in gfortran's round_4.f90 was nextafterl(0.10000000000000000000135525271560688L, -INFINITY) which caused an ulp addition rather than subtraction. Reported by John Marino @ DragonFlyBSD.
Diffstat (limited to 'lib/libm')
-rw-r--r--lib/libm/src/ld80/s_nextafterl.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libm/src/ld80/s_nextafterl.c b/lib/libm/src/ld80/s_nextafterl.c
index 0c28b02101e..39de3fa9607 100644
--- a/lib/libm/src/ld80/s_nextafterl.c
+++ b/lib/libm/src/ld80/s_nextafterl.c
@@ -25,7 +25,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;
+ int32_t esx,esy;
GET_LDOUBLE_WORDS(esx,hx,lx,x);
GET_LDOUBLE_WORDS(esy,hy,ly,y);
@@ -43,8 +44,8 @@ nextafterl(long double x, long double y)
u = u * u; /* raise underflow flag */
return x;
}
- if(esx<0x8000) { /* x > 0 */
- if(ix>iy||((ix==iy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
+ if(esx>=0) { /* x > 0 */
+ if(esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
/* x > y, x -= ulp */
if(lx==0) {
if ((hx&0x7fffffff)==0) esx -= 1;
@@ -59,7 +60,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||(esx>esy||((esx==esy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){
/* x < y, x -= ulp */
if(lx==0) {
if ((hx&0x7fffffff)==0) esx -= 1;