From 3725fb7edab8b20e1c16ac99e6bda426e0074962 Mon Sep 17 00:00:00 2001 From: stefanf Date: Sat, 9 Oct 2004 17:14:28 +0000 Subject: Use the FP_ILOG macros from rather than hardcoded return values. Also be prepared for FP_ILOGBNAN != INT_MAX. Reviewed by: md5 --- lib/msun/src/s_ilogb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/msun/src/s_ilogb.c') diff --git a/lib/msun/src/s_ilogb.c b/lib/msun/src/s_ilogb.c index ef24efa..69077af 100644 --- a/lib/msun/src/s_ilogb.c +++ b/lib/msun/src/s_ilogb.c @@ -16,10 +16,13 @@ static char rcsid[] = "$FreeBSD$"; /* ilogb(double x) * return the binary exponent of non-zero x - * ilogb(0) = 0x80000001 - * ilogb(inf/NaN) = 0x7fffffff (no signal is raised) + * ilogb(0) = FP_ILOGB0 + * ilogb(NaN) = FP_ILOGBNAN (no signal is raised) + * ilogb(inf) = INT_MAX (no signal is raised) */ +#include + #include "math.h" #include "math_private.h" @@ -31,7 +34,7 @@ static char rcsid[] = "$FreeBSD$"; hx &= 0x7fffffff; if(hx<0x00100000) { if((hx|lx)==0) - return 0x80000001; /* ilogb(0) = 0x80000001 */ + return FP_ILOGB0; else /* subnormal x */ if(hx==0) { for (ix = -1043; lx>0; lx<<=1) ix -=1; @@ -41,5 +44,6 @@ static char rcsid[] = "$FreeBSD$"; return ix; } else if (hx<0x7ff00000) return (hx>>20)-1023; - else return 0x7fffffff; + else if (hx>0x7ff00000 || lx!=0) return FP_ILOGBNAN; + else return INT_MAX; } -- cgit v1.1