#153468 - Rajveer - Mon Mar 31, 2008 2:18 pm
I can't seem to find a floating point sqrt function in Devkitarm. I need this during level load as I get inaccuracies with fixed-point in things like normal calculations with extreme polygons. ANSI C says it should have sqrt, and Newlib says it has a function sqrtf but it's not defined when I try to compile, any ideas?
#153469 - M3d10n - Mon Mar 31, 2008 2:27 pm
Did you try adding this to your code?
I had to use atan2f() because I was too lazy to write a fixed-point version and that's all I hd to do to access the fp math functions.
#153470 - Rajveer - Mon Mar 31, 2008 2:33 pm
Yup already including math.h. Just to make sure I tried atanf() which compiles, but sqrt or sqrtf don't.
#153472 - M3d10n - Mon Mar 31, 2008 2:47 pm
I did a text search on the include files. Both sqrt and sqrtf are in math.h, but they are under #ifndef _REENT_ONLY. I couldn't find it defined anywhere, but you could try looking at it.
You could also try including fastmath.h and using fast_sqrtf(). I can't check if that one will compile right now.
#153473 - Rajveer - Mon Mar 31, 2008 2:57 pm
Fast_sqrtf is defined as
Code: |
#define sqrtf(x) fast_sqrtf(x) |
but I too can't find sqrtf defined anywhere. Including fastmath.h and trying to compile fast_sqrtf also gives an implicit declaration warning and an undefined reference error :(
#153477 - elhobbs - Mon Mar 31, 2008 4:16 pm
#153478 - Rajveer - Mon Mar 31, 2008 4:52 pm
My bad, I thought including math.h was all I had to do, didn't know it was part of a separate library. Cheers!