Re: A85: Square roots


[Prev][Next][Index][Thread]

Re: A85: Square roots



I believe if you use Newton's method of finding roots you can do this
easily

If you don't know Newton's method here it is:
     	Let X equal the number you want to find the square root of.
	Let TOLERANCE be the accuracy of the root (1.0 * 10 ^ -7)
	When programming, multiply by the inverse, don't divide (it's
slow)
	Multiply X by 0.5 and let this equal the current value of the
root (call it ROOT)
	Make a label here.
	ROOT = (ROOT + (X / ROOT)) * 0.5
	Put (ROOT * ROOT) - X in another spot for reference (call it
TEMP)
	Get absolute value of TEMP (if you don't know how ask me)
	Compare TEMP and TOLERANCE
	While TEMP > TOLERANCE continue jumping to your label.
	Other wise you got your root

I'm definitely not the best at assembly but I can visualize how this
would look, if you have any questions or corrections let me know.

Erik Huizing's method will work also but I'm sure this is much more
efficient code and you won't have to calculate all the mod crap.  Besides
this is Z-80 not BASIC

Kakos
egillespie@juno.com


Follow-Ups: References: