svn commit: r234535 - stable/9/lib/msun/src

David Schultz das at FreeBSD.org
Sat Apr 21 07:00:40 UTC 2012


Author: das
Date: Sat Apr 21 07:00:39 2012
New Revision: 234535
URL: http://svn.freebsd.org/changeset/base/234535

Log:
  MFC r233973:
    Fix bugs in remquo{,f,l}.

Modified:
  stable/9/lib/msun/src/s_remquo.c
  stable/9/lib/msun/src/s_remquof.c
  stable/9/lib/msun/src/s_remquol.c
Directory Properties:
  stable/9/lib/msun/   (props changed)

Modified: stable/9/lib/msun/src/s_remquo.c
==============================================================================
--- stable/9/lib/msun/src/s_remquo.c	Sat Apr 21 07:00:00 2012	(r234534)
+++ stable/9/lib/msun/src/s_remquo.c	Sat Apr 21 07:00:39 2012	(r234535)
@@ -51,7 +51,7 @@ remquo(double x, double y, int *quo)
 		goto fixup;	/* |x|<|y| return x or x-y */
 	    }
 	    if(lx==ly) {
-		*quo = 1;
+		*quo = (sxy ? -1 : 1);
 		return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
 	    }
 	}
@@ -114,6 +114,7 @@ remquo(double x, double y, int *quo)
 
     /* convert back to floating value and restore the sign */
 	if((hx|lx)==0) {			/* return sign(x)*0 */
+	    q &= 0x7fffffff;
 	    *quo = (sxy ? -q : q);
 	    return Zero[(u_int32_t)sx>>31];
 	}
@@ -129,9 +130,9 @@ remquo(double x, double y, int *quo)
 		lx = (lx>>n)|((u_int32_t)hx<<(32-n));
 		hx >>= n;
 	    } else if (n<=31) {
-		lx = (hx<<(32-n))|(lx>>n); hx = sx;
+		lx = (hx<<(32-n))|(lx>>n); hx = 0;
 	    } else {
-		lx = hx>>(n-32); hx = sx;
+		lx = hx>>(n-32); hx = 0;
 	    }
 	}
 fixup:

Modified: stable/9/lib/msun/src/s_remquof.c
==============================================================================
--- stable/9/lib/msun/src/s_remquof.c	Sat Apr 21 07:00:00 2012	(r234534)
+++ stable/9/lib/msun/src/s_remquof.c	Sat Apr 21 07:00:39 2012	(r234535)
@@ -46,7 +46,7 @@ remquof(float x, float y, int *quo)
 	    q = 0;
 	    goto fixup;	/* |x|<|y| return x or x-y */
 	} else if(hx==hy) {
-	    *quo = 1;
+	    *quo = (sxy ? -1 : 1);
 	    return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/
 	}
 
@@ -88,6 +88,7 @@ remquof(float x, float y, int *quo)
 
     /* convert back to floating value and restore the sign */
 	if(hx==0) {				/* return sign(x)*0 */
+	    q &= 0x7fffffff;
 	    *quo = (sxy ? -q : q);
 	    return Zero[(u_int32_t)sx>>31];
 	}

Modified: stable/9/lib/msun/src/s_remquol.c
==============================================================================
--- stable/9/lib/msun/src/s_remquol.c	Sat Apr 21 07:00:00 2012	(r234534)
+++ stable/9/lib/msun/src/s_remquol.c	Sat Apr 21 07:00:39 2012	(r234535)
@@ -96,7 +96,7 @@ remquol(long double x, long double y, in
 		goto fixup;	/* |x|<|y| return x or x-y */
 	    }
 	    if(ux.bits.manh==uy.bits.manh && ux.bits.manl==uy.bits.manl) {
-		*quo = 1;
+		*quo = (sxy ? -1 : 1);
 		return Zero[sx];	/* |x|=|y| return x*0*/
 	    }
 	}
@@ -138,6 +138,7 @@ remquol(long double x, long double y, in
 
     /* convert back to floating value and restore the sign */
 	if((hx|lx)==0) {			/* return sign(x)*0 */
+	    q &= 0x7fffffff;
 	    *quo = (sxy ? -q : q);
 	    return Zero[sx];
 	}


More information about the svn-src-stable-9 mailing list