diff options
Diffstat (limited to 'sysdeps/ieee754/dbl-64/e_log10.c')
-rw-r--r-- | sysdeps/ieee754/dbl-64/e_log10.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/sysdeps/ieee754/dbl-64/e_log10.c b/sysdeps/ieee754/dbl-64/e_log10.c index 9fce937085..ab5069e58e 100644 --- a/sysdeps/ieee754/dbl-64/e_log10.c +++ b/sysdeps/ieee754/dbl-64/e_log10.c @@ -46,39 +46,40 @@ #include <math.h> #include <math_private.h> -static const double -two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ -ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */ -log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */ -log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */ - -static const double zero = 0.0; +static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ +static const double ivln10 = 4.34294481903251816668e-01; /* 0x3FDBCB7B, 0x1526E50E */ +static const double log10_2hi = 3.01029995663611771306e-01; /* 0x3FD34413, 0x509F6000 */ +static const double log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */ double -__ieee754_log10(double x) +__ieee754_log10 (double x) { - double y,z; - int32_t i,k,hx; - u_int32_t lx; + double y, z; + int32_t i, k, hx; + u_int32_t lx; - EXTRACT_WORDS(hx,lx,x); + EXTRACT_WORDS (hx, lx, x); - k=0; - if (hx < 0x00100000) { /* x < 2**-1022 */ - if (__builtin_expect(((hx&0x7fffffff)|lx)==0, 0)) - return -two54/(x-x); /* log(+-0)=-inf */ - if (__builtin_expect(hx<0, 0)) - return (x-x)/(x-x); /* log(-#) = NaN */ - k -= 54; x *= two54; /* subnormal number, scale up x */ - GET_HIGH_WORD(hx,x); - } - if (__builtin_expect(hx >= 0x7ff00000, 0)) return x+x; - k += (hx>>20)-1023; - i = ((u_int32_t)k&0x80000000)>>31; - hx = (hx&0x000fffff)|((0x3ff-i)<<20); - y = (double)(k+i); - SET_HIGH_WORD(x,hx); - z = y*log10_2lo + ivln10*__ieee754_log(x); - return z+y*log10_2hi; + k = 0; + if (hx < 0x00100000) + { /* x < 2**-1022 */ + if (__builtin_expect (((hx & 0x7fffffff) | lx) == 0, 0)) + return -two54 / (x - x); /* log(+-0)=-inf */ + if (__builtin_expect (hx < 0, 0)) + return (x - x) / (x - x); /* log(-#) = NaN */ + k -= 54; + x *= two54; /* subnormal number, scale up x */ + GET_HIGH_WORD (hx, x); + } + if (__builtin_expect (hx >= 0x7ff00000, 0)) + return x + x; + k += (hx >> 20) - 1023; + i = ((u_int32_t) k & 0x80000000) >> 31; + hx = (hx & 0x000fffff) | ((0x3ff - i) << 20); + y = (double) (k + i); + SET_HIGH_WORD (x, hx); + z = y * log10_2lo + ivln10 * __ieee754_log (x); + return z + y * log10_2hi; } + strong_alias (__ieee754_log10, __log10_finite) |