summaryrefslogtreecommitdiffstats
path: root/lib/msun/src/s_logb.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/msun/src/s_logb.c')
-rw-r--r--lib/msun/src/s_logb.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/msun/src/s_logb.c b/lib/msun/src/s_logb.c
index 5c6ea6c..f667bf2 100644
--- a/lib/msun/src/s_logb.c
+++ b/lib/msun/src/s_logb.c
@@ -23,6 +23,9 @@ static char rcsid[] = "$FreeBSD$";
#include "math.h"
#include "math_private.h"
+static const double
+two54 = 1.80143985094819840000e+16; /* 43500000 00000000 */
+
double
logb(double x)
{
@@ -31,8 +34,11 @@ logb(double x)
ix &= 0x7fffffff; /* high |x| */
if((ix|lx)==0) return -1.0/fabs(x);
if(ix>=0x7ff00000) return x*x;
- if((ix>>=20)==0) /* IEEE 754 logb */
- return -1022.0;
- else
- return (double) (ix-1023);
+ if(ix<0x00100000) {
+ x *= two54; /* convert subnormal x to normal */
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+ return (float) ((ix>>20)-1023-54);
+ } else
+ return (double) ((ix>>20)-1023);
}
OpenPOWER on IntegriCloud