i need a fast sqrt or Inverse sqrt for unsigned longs

Started by
4 comments, last by vaneger 20 years ago
any one have somethign that will work with those?
Advertisement
usually you can get away with not using the square root for most game involved things. comparing distance squared is just as good as comparing distance, as long as you are just worried about relative distances. but otherwise just use the square root function. you can use a tailor series for the square root, but AFAIK that''s what the processor already uses. either that or a lookup table. either way, the processor will most likely be better at getting the square root faster than what you can come up with

-me
Too true, when it comes to square roots let the sqrt command worry about it
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
well im currently using a lookup table but a faster sqrt that works for unsigned longs would be great.
Give this a go, I think it''s out of the Decent source code.
inline const long isqrt(register unsigned long x) {	register unsigned long r, nr, m;	r= 0;	m= 0x40000000;	do {		nr= r + m;		if (nr<=x) {			x-= nr;			r= nr + m;		}		r>>= 1;		m>>= 2;	} while (m!=0);	if (x>r) r+= 1;	return r;}
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
lots and lots of sqrt
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3

This topic is closed to new replies.

Advertisement