Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Square Root (http://www.chiefdelphi.com/forums/showthread.php?t=25276)

bludstayne 14-02-2004 12:02

Square Root
 
How can I implement a decently fast square root function? Is there any inline assembly I can use?

Paul 14-02-2004 12:48

Re: Square Root
 
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

Re: Square Root
 
Quote:

Originally Posted by bludstayne
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.

Paul 14-02-2004 14:48

Re: Square Root
 
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;
}


All times are GMT -5. The time now is 19:22.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi