The sqrt algorythm

Post Reply
intre
Posts: 43
Joined: Sat Nov 08, 2008 6:28 pm
Location: Moscow
Contact:

The sqrt algorythm

Post by intre »

Code: Select all

sqrt:
	rslt = L
	div = L 
	if L <= 0 { ret }
	while (1){
		div = (L / div + div) / 2
		if rslt > div { rslt = div }
		else { ret }
	}
ret
Store your value in variable L, get in variable rslt.
Example:

Code: Select all

L = 121
sqrt
print("$rslt", 0, 0, BLACK)
- this will print "11"
Post Reply