double fsqrt (double y) {
double x, z, tempf;
unsigned long *tfptr = ((unsigned long *)&tempf) + 1;
tempf = y;
*tfptr = (0xbfcdd90a - *tfptr)>>1; /* estimate of 1/sqrt(y) */
x = tempf;
z = y*0.5; /* hoist out the “/2” */
x = (1.5*x) - (x*x)*(x*z); /* iteration formula */
x = (1.5*x) – (x*x)*(x*z);
x = (1.5*x) – (x*x)*(x*z);
x = (1.5*x) – (x*x)*(x*z);
x = (1.5*x) – (x*x)*(x*z);
return x*y;
}
[/quote]
No divides!!!!! This is important because the divide can be 5 to 40 times slower than a multiply on a DSP or micro controller.