Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating point library for embedded application

I'm developing program for Cortex-M3. It doesn't have floating point coprocessor. Standard C library can emulate floating point operations, but I don't use it due to its size.

Is there any good and free c library, which can emulate floating point arithmetics, targeted on ARM processors? Currently, when I use floating point operators I have such linkage errors:

undefined reference to `__adddf3'
undefined reference to `__subdf3'
undefined reference to `__divdf3'
undefined reference to `__extendsfdf2'
undefined reference to `__muldf3'

So probably such library should implement them.

like image 721
cos Avatar asked Oct 23 '25 18:10

cos


2 Answers

Would you not be better off (performance and size wise) using fixed point? For simple arithmetic, this is trivial to implement either directly or with a function interface. If you could bare to use C++, using operator overloading could make the use of fixed almost seamless (at no runtime overhead compared to a C function interface).

If you have more complex requirements (trig, roots etc), a good fixed-point library is presented in this Dr. Dobb's Article.

like image 81
Clifford Avatar answered Oct 26 '25 09:10

Clifford


If you want to perform your floating arithmetic using built in operators, then you'll need to provide the library routines that the compiler expects, so you'd end up with something that's likely to be as large as the library that came with the compiler.

You likely have the source code to the compiler's floating support routines, so if you want to look at them to see if you can improve them that's probably your best chance. If you don't think that'll work for whatever reason, you should talk to your compiler vendor about the requirements the compiler expects of the floating support routines and the best way to replace the vendor's library.

If you want to circumvent the compiler's requirements, you'll probably need to avoid using the built in operators and perform you arithmetic using explicit function calls. I have no experience with 3rd party floating point library routines, so unfortunately I can't point you to an possible good alternatives.

like image 45
Michael Burr Avatar answered Oct 26 '25 07:10

Michael Burr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!