diff options
author | bde <bde@FreeBSD.org> | 2005-12-03 11:57:19 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2005-12-03 11:57:19 +0000 |
commit | a8b03f7b44193e86cc1e0f70b2296e57b237d5ab (patch) | |
tree | a8e7e0521a27a9ebd09a0c4d4027dd7946ecd0c1 /lib/msun/src/s_logbf.c | |
parent | caf571b462b163937df446465fdc7971de6a42f0 (diff) | |
download | FreeBSD-src-a8b03f7b44193e86cc1e0f70b2296e57b237d5ab.zip FreeBSD-src-a8b03f7b44193e86cc1e0f70b2296e57b237d5ab.tar.gz |
Fixed fdlibm[+cygnus] logbf() and logb() on denormals. Adjustment
according to the highest nonzero bit in a denormal was missing.
fdlibm ilogbf() and ilogb() have always had the adjustment, but only
use a small part of their method for handling denormals; use the
normalization method in log[f]() for the main part.
Diffstat (limited to 'lib/msun/src/s_logbf.c')
-rw-r--r-- | lib/msun/src/s_logbf.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/msun/src/s_logbf.c b/lib/msun/src/s_logbf.c index e673d96..97ccd02 100644 --- a/lib/msun/src/s_logbf.c +++ b/lib/msun/src/s_logbf.c @@ -20,6 +20,9 @@ static char rcsid[] = "$FreeBSD$"; #include "math.h" #include "math_private.h" +static const float +two25 = 3.355443200e+07; /* 0x4c000000 */ + float logbf(float x) { @@ -28,8 +31,11 @@ logbf(float x) ix &= 0x7fffffff; /* high |x| */ if(ix==0) return (float)-1.0/fabsf(x); if(ix>=0x7f800000) return x*x; - if((ix>>=23)==0) /* IEEE 754 logb */ - return -126.0; - else - return (float) (ix-127); + if(ix<0x00800000) { + x *= two25; /* convert subnormal x to normal */ + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + return (float) ((ix>>23)-127-25); + } else + return (float) ((ix>>23)-127); } |