by roland35 · 7y ago · 0 comments
Even with a floating point processor you need to be careful when switching into and out of interrupts! The floating point core has it's own set of registers you need to keep track of. Doubles are even worse!
Basically it is almost always better to use integers when you can, and be aware of what types you are using (always important in C anyways).
Called cos() when you meant cosf()? Done in software.
Multiplied by 2.25 when you meant 2.25f? Done in software.
-Wdouble-promotion will help you find those performance bugs.
> Basically it is almost always better to use integers when you can
I'd say: understand the limitations of FP, but it's almost always better to use them unless you have some particular precision or performance requirement. Then again, my experience of FP is mostly in graphics, where IEEE 754 single precision is good enough for almost anything you'd want, and hardware FP is commonplace.
Maybe there are better ways to do it, I could be wrong!