View Full Version : Square Root
bludstayne
14-02-2004, 12:02
How can I implement a decently fast square root function? Is there any inline assembly I can use?
Do you need to take the sqr of the number every loop? If you don't then just find the sqr of the particular number and define it as a constant. If you still need a fast sqr function let me know. Private message me cause I normally forget where I've posted recently lol. :D
Mike Bonham
14-02-2004, 13:15
How can I implement a decently fast square root function? Is there any inline assembly I can use?
I'm not a programmer, and I'm not sure if this applies to your question or not, but check our Question of the Day ...
http://www.metalinmotion.com
If what you find there is of no help, I'll mention your post to our programming sub-team.
try this bit of code, it should give you a quick way to find square roots... but only for ints. It is accurate up to a certian point it should have enough accuracy for anything that needs to be done with our robots. If you need anything else let me know.
inline int sroot(int n)
{
int c = 0; int a = 1;
do {n -= a; a += 2; ++c;}
while (n > 0);
return c;
}
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.