jin Otanashi wrote:
Les Morgan wrote:You're approximation algorithm is flawed:
(N*N)/(2N) -> infinity. Your method is divergent.
you mean i need to do like (high * low )/2 ?
You need to have an algo that converges to your approximation, the formula you have does not.
I did a quick and dirty little algo and this worked for me if I don't be too crazy with it--just put the target number in for the guess and it brings thing around to a good approximation:
dTarget is the number you want the squareroot
dTrial is the guess (put dTarget in here for a start)
dTolerance is the error you are willing to accept (0.0001 seems to work well)