86 ln2_hi = 6.93147180369123816490e-01,
87 ln2_lo = 1.90821492927058770002e-10,
88 two54 = 1.80143985094819840000e+16,
89 Lp1 = 6.666666666666735130e-01,
90 Lp2 = 3.999999999940941908e-01,
91 Lp3 = 2.857142874366239149e-01,
92 Lp4 = 2.222219843214978396e-01,
93 Lp5 = 1.818357216161805012e-01,
94 Lp6 = 1.531383769920937332e-01,
95 Lp7 = 1.479819860511658591e-01;
97 static double zero = 0.0;
100 double log1p(
double x)
106 double hfsq,f,c=0,s,z,R,u;
113 if (hx < 0x3FDA827A) {
115 if(x==-1.0)
return -two54/
zero;
116 else return (x-x)/(x-x);
125 if(hx>0||hx<=((
int)0xbfd2bec3)) {
128 if (hx >= 0x7ff00000)
return x+x;
134 c = (k>0)? 1.0-(u-x):x-(u-1.0);
144 __HI(u) = hu|0x3ff00000;
147 __HI(u) = hu|0x3fe00000;
148 hu = (0x00100000-hu)>>2;
155 else {c += k*ln2_lo;
return k*ln2_hi+c;}}
156 R = hfsq*(1.0-0.66666666666666666*f);
157 if(k==0)
return f-R;
else
158 return k*ln2_hi-((R-(k*ln2_lo+c))-f);
162 R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
163 if(k==0)
return f-(hfsq-s*(hfsq+R));
else
164 return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);