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 > Math lib for fixed point type

#102575 - crabo - Fri Sep 15, 2006 10:33 am

Hi

Does somebody know a fixed point type library for DS including operators overloading and math functions like square root, trigonometric functions, matrixes, quaternions, ? ??

#102581 - juhees - Fri Sep 15, 2006 12:36 pm

crabo wrote:
Hi

Does somebody know a fixed point type library for DS including operators overloading and math functions like square root, trigonometric functions, matrixes, quaternions, ? ??


I'm working on one (for 2 days, so i don't have much ;-)
It's based on macros and c-functions (or assembly), but no overloading (i guess that would be slower, but i'm not shure. It depends on how good the compiler optimizes the code. I could try that and run some benchmarks when i have some time).
So far i just have:
ADD (whoho!)
SUB
MUL
DIV
SQRT
ABS

It's 16.16 fixed point numbers, but you can adjust that with one #define

What slows me down most is making shure the calculations are correct, so i'm coding like 3 lines of code for the fuction and 100 lines for correctness test and benchmark ;-)

I could share it when i have some more functions.

#102599 - memoni - Fri Sep 15, 2006 3:18 pm

There was some discussion over the other forum on the same topic:

http://forum.gbadev.org/viewtopic.php?t=6620

But that is just a start. One place to find some fixed point examples & libraries would be old (mid 90's) game and demo sources.

#102640 - relpats_eht - Fri Sep 15, 2006 9:09 pm

I have some C++ classes for fixed point numbers and some classes for matrices, vectors, and quaternions. I haven't much faith in the optimization of the matrix, vector, and quaternion classes, however, and the fixed point classes could use some work. Nonetheless, if you want them, you may pick them up here.
_________________
- relpats_eht