99 #ifdef POK_NEEDS_LIBMATH
102 #include "math_private.h"
104 static const double one = 1.0, tiny=1.0e-300;
107 __ieee754_sqrt(
double x)
110 int32_t sign = (int)0x80000000;
111 int32_t ix0,s0,q,m,t,i;
112 uint32_t r,t1,s1,ix1,q1;
114 EXTRACT_WORDS(ix0,ix1,x);
117 if((ix0&0x7ff00000)==0x7ff00000) {
123 if(((ix0&(~sign))|ix1)==0)
return x;
132 ix0 |= (ix1>>11); ix1 <<= 21;
134 for(i=0;(ix0&0x00100000)==0;i++) ix0<<=1;
136 ix0 |= (ix1>>(32-i));
140 ix0 = (ix0&0x000fffff)|0x00100000;
142 ix0 += ix0 + ((ix1&sign)>>31);
148 ix0 += ix0 + ((ix1&sign)>>31);
150 q = q1 = s0 = s1 = 0;
160 ix0 += ix0 + ((ix1&sign)>>31);
169 if((t<ix0)||((t==ix0)&&(t1<=ix1))) {
171 if(((t1&sign)==(uint32_t)sign)&&(s1&sign)==0) s0 += 1;
173 if (ix1 < t1) ix0 -= 1;
177 ix0 += ix0 + ((ix1&sign)>>31);
187 if (q1==(uint32_t)0xffffffff) { q1=0; q += 1;}
189 if (q1==(uint32_t)0xfffffffe) q+=1;
195 ix0 = (q>>1)+0x3fe00000;
197 if ((q&1)==1) ix1 |= sign;
199 INSERT_WORDS(z,ix0,ix1);