How to get square root for longlong type value

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. :wink:

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 ]

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

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.