input:
a = number to be squared
x = estimated result (can be any numberm but the better estimation the better
result)
output:
x = close to sqrt(a)
algorithm: execute this code as many times you need. usually 4-6 iterations give
enough precision.
x = (x + a/x)/2;
for fixed point you need to take care of division (choose on depending what
range/precision you want):
x = (x + a/(x>>10))>>1;
x = (x + (a<<5)/(x>>5))>>1;
x = (x + (a<<10)/x)>>1;
--
CLTR+C, porneL
The decision is maybe and that's final! [
http://ldreams.net ]
gg 989217, icy cucumber 145671338, sms 501454657, #amigapl (irc.pl)