123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #include "math.h"
- #include "math_private.h"
- static const double
- two54 = 1.80143985094819840000e+16,
- ivln10 = 4.34294481903251816668e-01,
- log10_2hi = 3.01029995663611771306e-01,
- log10_2lo = 3.69423907715893078616e-13;
- static const double zero = 0.0;
- double attribute_hidden __ieee754_log10(double x)
- {
- double y,z;
- int32_t i,k,hx;
- u_int32_t lx;
- EXTRACT_WORDS(hx,lx,x);
- k=0;
- if (hx < 0x00100000) {
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero;
- if (hx<0) return (x-x)/zero;
- k -= 54; x *= two54;
- GET_HIGH_WORD(hx,x);
- }
- if (hx >= 0x7ff00000) 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;
- }
- #ifndef _IEEE_LIBM
- double log10(double x)
- {
- double z = __ieee754_log10(x);
- if (_LIB_VERSION == _IEEE_ || isnan(x))
- return z;
- if (x <= 0.0) {
- if(x == 0.0)
- return __kernel_standard(x, x, 18);
- return __kernel_standard(x, x, 19);
- }
- return z;
- }
- #else
- strong_alias(__ieee754_log10, log10)
- #endif
- libm_hidden_def(log10)
|