gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > NDSLIB - Fixed Point Weirdness

#42887 - blaisef01 - Mon May 16, 2005 4:15 am

I keep on getting wrong answers with sqrtf32 in the NDSLib
eg: sqrtf32(16384) = 5792 (sqrt(2) << 12)
when it should be 8192 (sqrt(4) << 12)

I tried replacing the function with this:

static inline f32 sqrtf32(f32 a)
{
SQRT_CR = SQRT_64;

while(SQRT_CR & SQRT_BUSY);
SQRT_PARAM64 = ((int64)a) << 13; // i changed this from 12
while(SQRT_CR & SQRT_BUSY);
return SQRT_RESULT32;
}

And everything seems to be okay. I don't quite understand why. If someone wants to explain it would be handy.

Cheers

#42899 - Ethos - Mon May 16, 2005 1:24 pm

Were you trying to run it on ideas?

Because it is not working there.
_________________
Ethos' Homepage (Demos/NDS 3D Tutorial)