This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A patch for sysdeps/i386/fpu/s_nextafterl.c


The current sysdeps/i386/fpu/s_nextafterl.c is incorrect with

ld = LDBL_MIN;
ld = nextafterl (ld, LDBL_MIN / 2.0);
ld = nextafterl (ld, LDBL_MIN);

At this point, ld is

Sign	exponent	mantissa
0	0x0		0x8000000000000000

This is not a valid fp represenation. It should be

Sign	exponent	mantissa
0	0x1		0x8000000000000000

sysdeps/i386/fpu/s_fpclassifyl.c doesn't know how to handle it. It
returns FP_NORMAL incorrectly. I don't see it is a fpclassifyl bug
since the number is not valid. This patch works on both ia32 and ia64.


-- 
H.J. Lu (hjl@valinux.com)
--
2000-12-20  H.J. Lu  <hjl@gnu.org>

	* sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Handle
	change from denormal to normal correctly.

Index: sysdeps/i386/fpu/s_nextafterl.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/i386/fpu/s_nextafterl.c,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 s_nextafterl.c
--- sysdeps/i386/fpu/s_nextafterl.c	2000/12/19 23:15:29	1.1.1.3
+++ sysdeps/i386/fpu/s_nextafterl.c	2000/12/20 22:11:05
@@ -38,7 +38,7 @@ static char rcsid[] = "$NetBSD: $";
 {
 	u_int32_t hx,hy,ix,iy;
 	u_int32_t lx,ly;
-	int32_t esx,esy;
+	int16_t esx,esy;
 
 	GET_LDOUBLE_WORDS(esx,hx,lx,x);
 	GET_LDOUBLE_WORDS(esy,hy,ly,y);
@@ -56,7 +56,7 @@ static char rcsid[] = "$NetBSD: $";
 	    y = x*x;
 	    if(y==x) return y; else return x;	/* raise underflow flag */
 	}
-	if(esx<0x8000) {			/* x > 0 */
+	if(esx>=0) {			/* x > 0 */
 	    if(ix>iy||((ix==iy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
 	      /* x > y, x -= ulp */
 		if(lx==0) {
@@ -77,7 +77,7 @@ static char rcsid[] = "$NetBSD: $";
 		lx += 1;
 		if(lx==0) {
 		    hx += 1;
-		    if (hx==0)
+		    if (hx==0||(esx==0&&hx==0x80000000))
 			esx += 1;
 		}
 	    }
@@ -86,14 +86,10 @@ static char rcsid[] = "$NetBSD: $";
 	      /* x < y, x -= ulp */
 		if(lx==0) {
 		    if (hx <= 0x80000000) {
-		      if (esx == 0)
-			hx = 0;
-		      else {
 			esx -= 1;
 			hx = hx - 1;
 			if ((esx&0x7fff) > 0)
 			  hx |= 0x80000000;
-		      }
 		    } else
 		      hx -= 1;
 		}
@@ -102,7 +98,8 @@ static char rcsid[] = "$NetBSD: $";
 		lx += 1;
 		if(lx==0) {
 		    hx += 1;
-		    if (hx==0) esx += 1;
+		    if (hx==0||((esx&0x7fff)==0&&hx==0x80000000))
+			esx += 1;
 		}
 	    }
 	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]