summaryrefslogtreecommitdiffstats
path: root/lib/msun
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2004-10-09 17:14:28 +0000
committerstefanf <stefanf@FreeBSD.org>2004-10-09 17:14:28 +0000
commit3725fb7edab8b20e1c16ac99e6bda426e0074962 (patch)
treec98a83d29bb79c0bdb9d7f3e8cd2a9e4c64f4915 /lib/msun
parentac8a3b40c227c80e3d3ed4d0f2330bfd03b81844 (diff)
downloadFreeBSD-src-3725fb7edab8b20e1c16ac99e6bda426e0074962.zip
FreeBSD-src-3725fb7edab8b20e1c16ac99e6bda426e0074962.tar.gz
Use the FP_ILOG macros from <math.h> rather than hardcoded return values.
Also be prepared for FP_ILOGBNAN != INT_MAX. Reviewed by: md5
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/src/s_ilogb.c12
-rw-r--r--lib/msun/src/s_ilogbf.c7
2 files changed, 13 insertions, 6 deletions
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 <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 b65a365..ff58813 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;
}
OpenPOWER on IntegriCloud