PDA

View Full Version : How to get square root for longlong type value



Simpleton
02-09-2005, 11:44 PM
Hi!

I have a problem with calculating the vector's length. I use __sqrtx() from uglu.c and when I pass value greater then 2^32 (fixed limit) the function returns an undefined result. I have expanded type of passed value from GLfixed to __int64 but it has not helped. __sqrtx() uses Newton's method and does 6 compute iterations. May be it is not enough. I think I need more compute iterations, right? May be somebody can suggest any idea to help me resolve this problem. I will be very grateful. ;)

tobi
02-18-2005, 04:46 AM
Why you don't use your own sqrtx function. If you prefer the Newton Approximation then something like this:



Hope this helps....
Cheers Tobi

[ February 18, 2005: Message edited by: tobi ]

hmwill
02-18-2005, 06:33 AM
You could also just scale your input value before calling into the function; divide by 4 in the input corresponds to divide by 2 in the output.

- HM