diff options
| author | Stefan Farfeleder <stefanf@FreeBSD.org> | 2004-10-09 17:14:28 +0000 |
|---|---|---|
| committer | Stefan Farfeleder <stefanf@FreeBSD.org> | 2004-10-09 17:14:28 +0000 |
| commit | 552ebda9dd4765545c82c29bb3e8862532ce0cc4 (patch) | |
| tree | c98a83d29bb79c0bdb9d7f3e8cd2a9e4c64f4915 /lib | |
| parent | e2494b93fce6d94dee261a6a5f50aa736b93b485 (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/msun/src/s_ilogb.c | 12 | ||||
| -rw-r--r-- | lib/msun/src/s_ilogbf.c | 7 |
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/msun/src/s_ilogb.c b/lib/msun/src/s_ilogb.c index ef24efacde4d0..69077af334963 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 <limits.h> + #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; } diff --git a/lib/msun/src/s_ilogbf.c b/lib/msun/src/s_ilogbf.c index b65a365466803..ff588139a5c9c 100644 --- a/lib/msun/src/s_ilogbf.c +++ b/lib/msun/src/s_ilogbf.c @@ -17,6 +17,8 @@ static char rcsid[] = "$FreeBSD$"; #endif +#include <limits.h> + #include "math.h" #include "math_private.h" @@ -28,11 +30,12 @@ static char rcsid[] = "$FreeBSD$"; hx &= 0x7fffffff; if(hx<0x00800000) { if(hx==0) - return 0x80000001; /* ilogb(0) = 0x80000001 */ + return FP_ILOGB0; else /* subnormal x */ for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; return ix; } else if (hx<0x7f800000) return (hx>>23)-127; - else return 0x7fffffff; + else if (hx>0x7f800000) return FP_ILOGBNAN; + else return INT_MAX; } |
