Quote:

float IterSqrtf(float r, int numtries)

{

float m(0.0f);

float b(0.0f);

float currx=r;

float curry(0.0f);

float root(0.0f); //this is what gets returned

while(numtries--)

{

curry = (currx*currx) - r; //y1

//Check to see if curry is < 0

m = 2 * currx;

b = (-m*currx) + curry;

root = -b / m;

currx = root;

}

return root;

}

Here's an implementation from tricks of the 3d game programming gurus...it's faster than sqrt() and is always within 5% accuracy
Quote:

float Faster_Sqrtf(float f)

{

float result;

_asm

{

mov eax, f

sub eax, 0x3f800000

sar eax, 1

add eax, 0x3f800000

mov result, eax

}

return result;

}