30 #ifdef POK_NEEDS_LIBMATH
32 #include "math_private.h"
35 ln2 = 0.6931471805599452862268,
36 two54 = 1.80143985094819840000e+16,
37 Lg1 = 6.666666666666735130e-01,
38 Lg2 = 3.999999999940941908e-01,
39 Lg3 = 2.857142874366239149e-01,
40 Lg4 = 2.222219843214978396e-01,
41 Lg5 = 1.818357216161805012e-01,
42 Lg6 = 1.531383769920937332e-01,
43 Lg7 = 1.479819860511658591e-01;
45 static const double zero = 0.0;
48 __ieee754_log2(
double x)
50 double hfsq,f,s,z,R,w,t1,t2,dk;
54 EXTRACT_WORDS(hx,lx,x);
57 if (hx < 0x00100000) {
58 if (((hx&0x7fffffff)|lx)==0)
60 if (hx<0)
return (x-x)/zero;
64 if (hx >= 0x7ff00000)
return x+x;
67 i = (hx+0x95f64)&0x100000;
68 SET_HIGH_WORD(x,hx|(i^0x3ff00000));
72 if((0x000fffff&(2+hx))<3) {
75 R = f*f*(0.5-0.33333333333333333*f);
76 return (dk-(R-f)/ln2);
83 t1= w*(Lg2+w*(Lg4+w*Lg6));
84 t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
89 return (dk-(hfsq-s*(hfsq+R)-f)/ln2);
91 return (dk-((s*(f-R))-f)/ln2);