about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/e_ilogb.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/dbl-64/e_ilogb.c')
-rw-r--r--sysdeps/ieee754/dbl-64/e_ilogb.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/sysdeps/ieee754/dbl-64/e_ilogb.c b/sysdeps/ieee754/dbl-64/e_ilogb.c
index 0452a71fb8..1e338a59c1 100644
--- a/sysdeps/ieee754/dbl-64/e_ilogb.c
+++ b/sysdeps/ieee754/dbl-64/e_ilogb.c
@@ -25,30 +25,39 @@ static char rcsid[] = "$NetBSD: s_ilogb.c,v 1.9 1995/05/10 20:47:28 jtc Exp $";
 #include <math.h>
 #include <math_private.h>
 
-int __ieee754_ilogb(double x)
+int
+__ieee754_ilogb (double x)
 {
-	int32_t hx,lx,ix;
+  int32_t hx, lx, ix;
 
-	GET_HIGH_WORD(hx,x);
-	hx &= 0x7fffffff;
-	if(hx<0x00100000) {
-	    GET_LOW_WORD(lx,x);
-	    if((hx|lx)==0)
-		return FP_ILOGB0;	/* ilogb(0) = FP_ILOGB0 */
-	    else			/* subnormal x */
-		if(hx==0) {
-		    for (ix = -1043; lx>0; lx<<=1) ix -=1;
-		} else {
-		    for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
-		}
-	    return ix;
+  GET_HIGH_WORD (hx, x);
+  hx &= 0x7fffffff;
+  if (hx < 0x00100000)
+    {
+      GET_LOW_WORD (lx, x);
+      if ((hx | lx) == 0)
+	return FP_ILOGB0;               /* ilogb(0) = FP_ILOGB0 */
+      else                              /* subnormal x */
+      if (hx == 0)
+	{
+	  for (ix = -1043; lx > 0; lx <<= 1)
+	    ix -= 1;
 	}
-	else if (hx<0x7ff00000) return (hx>>20)-1023;
-	else if (FP_ILOGBNAN != INT_MAX) {
-	    /* ISO C99 requires ilogb(+-Inf) == INT_MAX.  */
-	    GET_LOW_WORD(lx,x);
-	    if(((hx^0x7ff00000)|lx) == 0)
-		return INT_MAX;
+      else
+	{
+	  for (ix = -1022, hx <<= 11; hx > 0; hx <<= 1)
+	    ix -= 1;
 	}
-	return FP_ILOGBNAN;
+      return ix;
+    }
+  else if (hx < 0x7ff00000)
+    return (hx >> 20) - 1023;
+  else if (FP_ILOGBNAN != INT_MAX)
+    {
+      /* ISO C99 requires ilogb(+-Inf) == INT_MAX.  */
+      GET_LOW_WORD (lx, x);
+      if (((hx ^ 0x7ff00000) | lx) == 0)
+	return INT_MAX;
+    }
+  return FP_ILOGBNAN;
 }