about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-03-17 04:08:05 +0000
committerUlrich Drepper <drepper@redhat.com>1997-03-17 04:08:05 +0000
commit1908c0864174733623fdc1de5126956594a78baf (patch)
tree5f071084808669f1999b449f4aa4f902dd7f2320
parent31d782281541fdec957710e9799d177451dbbe32 (diff)
downloadglibc-1908c0864174733623fdc1de5126956594a78baf.tar.gz
glibc-1908c0864174733623fdc1de5126956594a78baf.tar.xz
glibc-1908c0864174733623fdc1de5126956594a78baf.zip
Rewrite to return -1 for -inf.
-rw-r--r--sysdeps/libm-ieee754/s_isinf.c13
-rw-r--r--sysdeps/libm-ieee754/s_isinff.c11
-rw-r--r--sysdeps/libm-ieee754/s_isinfl.c10
3 files changed, 18 insertions, 16 deletions
diff --git a/sysdeps/libm-ieee754/s_isinf.c b/sysdeps/libm-ieee754/s_isinf.c
index b35fc1c41c..d3c2cb55b7 100644
--- a/sysdeps/libm-ieee754/s_isinf.c
+++ b/sysdeps/libm-ieee754/s_isinf.c
@@ -1,5 +1,6 @@
 /*
  * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
  * Public domain.
  */
 
@@ -8,7 +9,7 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
 #endif
 
 /*
- * isinf(x) returns 1 is x is inf, else 0;
+ * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
  * no branching!
  */
 
@@ -22,12 +23,12 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
 	double x;
 #endif
 {
-	int32_t hx,lx;
+	u_int32_t hx;
+	int32_t lx;
 	EXTRACT_WORDS(hx,lx,x);
-	hx &= 0x7fffffff;
-	hx ^= 0x7ff00000;
-	hx |= lx;
-	return (hx == 0);
+	lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
+	lx |= -lx;
+	return ~(lx >> 31) & (1 - ((hx >> 30) & 2));
 }
 weak_alias (__isinf, isinf)
 #ifdef NO_LONG_DOUBLE
diff --git a/sysdeps/libm-ieee754/s_isinff.c b/sysdeps/libm-ieee754/s_isinff.c
index 1d81f15986..9acc0df6ec 100644
--- a/sysdeps/libm-ieee754/s_isinff.c
+++ b/sysdeps/libm-ieee754/s_isinff.c
@@ -8,7 +8,7 @@ static char rcsid[] = "$NetBSD: s_isinff.c,v 1.3 1995/05/11 23:20:21 jtc Exp $";
 #endif
 
 /*
- * isinff(x) returns 1 is x is inf, else 0;
+ * isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0;
  * no branching!
  */
 
@@ -22,10 +22,11 @@ static char rcsid[] = "$NetBSD: s_isinff.c,v 1.3 1995/05/11 23:20:21 jtc Exp $";
 	float x;
 #endif
 {
-	int32_t ix;
+	int32_t ix,t;
 	GET_FLOAT_WORD(ix,x);
-	ix &= 0x7fffffff;
-	ix ^= 0x7f800000;
-	return (ix == 0);
+	t = ix & 0x7fffffff;
+	t ^= 0x7f800000;
+	t |= -t;
+	return ~(t >> 31) & (1 - ((ix & 0x80000000) >> 30));
 }
 weak_alias (__isinff, isinff)
diff --git a/sysdeps/libm-ieee754/s_isinfl.c b/sysdeps/libm-ieee754/s_isinfl.c
index 22dff75444..b499821441 100644
--- a/sysdeps/libm-ieee754/s_isinfl.c
+++ b/sysdeps/libm-ieee754/s_isinfl.c
@@ -9,7 +9,7 @@ static char rcsid[] = "$NetBSD: $";
 #endif
 
 /*
- * isinfl(x) returns 1 is x is inf, else 0;
+ * isinfl(x) returns 1 if x is inf, -1 if x is -inf, else 0;
  * no branching!
  */
 
@@ -25,9 +25,9 @@ static char rcsid[] = "$NetBSD: $";
 {
 	int32_t se,hx,lx;
 	GET_LDOUBLE_WORDS(se,hx,lx,x);
-	se &= 0x7fff;
-	se ^= 0x7fff;
-	se |= hx | lx;
-	return (se == 0);
+	hx |= lx | ((se & 0x7fff) ^ 0x7fff);
+	hx |= -hx;
+	se &= 0x8000;
+	return ~(hx >> 31) & (1 - (se >> 14));
 }
 weak_alias (__isinfl, isinfl)