about summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-96/s_ilogbl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/ldbl-96/s_ilogbl.c')
-rw-r--r--sysdeps/ieee754/ldbl-96/s_ilogbl.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sysdeps/ieee754/ldbl-96/s_ilogbl.c b/sysdeps/ieee754/ldbl-96/s_ilogbl.c
index d44229dcda..9688f5af8f 100644
--- a/sysdeps/ieee754/ldbl-96/s_ilogbl.c
+++ b/sysdeps/ieee754/ldbl-96/s_ilogbl.c
@@ -20,10 +20,12 @@ static char rcsid[] = "$NetBSD: $";
 
 /* ilogbl(long double x)
  * return the binary exponent of non-zero x
- * ilogbl(0) = 0x80000001
- * ilogbl(inf/NaN) = 0x7fffffff (no signal is raised)
+ * ilogbl(0) = FP_ILOGB0
+ * ilogbl(NaN) = FP_ILOGBNAN (no signal is raised)
+ * ilogbl(+-Inf) = INT_MAX (no signal is raised)
  */
 
+#include <limits.h>
 #include "math.h"
 #include "math_private.h"
 
@@ -51,6 +53,9 @@ static char rcsid[] = "$NetBSD: $";
 	    return ix;
 	}
 	else if (es<0x7fff) return es-0x3fff;
-	else return FP_ILOGBNAN;
+	else if (FP_ILOGBNAN != INT_MAX && (hx|lx) == 0)
+	    /* ISO C99 requires ilogbl(+-Inf) == INT_MAX.  */
+	    return INT_MAX;
+	return FP_ILOGBNAN;
 }
 weak_alias (__ilogbl, ilogbl)