Cortex-M0 based MCUs are notable for their low cost and relatively smaller amount of available flash memory. If you wish to use floating point operations but are running tight on space, QFPlib is a great alternative. The core single-precision floating-point add/sub/mul/div/cmp operations take less than 400 bytes. According to QFPlib’s author, the corresponding routines in the GCC native library, by contrast, are over 2700 bytes in size, and the whole M0 library, including some trigonometric routines, comes in just slightly over 1K bytes.
QFPlib is even smaller than floating-point routines for other micros, including some such as the one for MSP430, which is known to have high code density. This table is a screencap from the author’s page at https://www.quinapalus.com/qfplib.html This is a comparison for the core arithmetic routines only:
But how about the downsides of QFPlib? There are two major ones:
1. QFPlib is released using GNU GPL V2 license with alternate licensing possible from the author. This means that your code will also have to be released under GPL V2 if you use QFPLib (however, see below).
2. You have to manually call QFPlib functions to perform even the basic operations such as add, e.g.: instead of writing “float_a + float_b”, you write “qfp_fadd(float_a, float_b)”
For licensing issues for a commercial firmware developer, practically this means that you can try out QFPlib if you are running low in memory, and if you later want to use it in a final product where you will not be releasing your code under GPL, then you will have to contact the author and purchase a commercial use license. I do not know what the cost of a commercial license is, but the author has said that it is reasonable.
Regarding ease of use, if you are using JumpStart C++ for Cortex, now you can use QFPlib by just enabling it with a checkbox:
Once done, your (single precision) floating-point operations will be done “automagically” using the compact QFPlib with no source code changes needed! Just write “float_a + float_b”, and QFPlib will be used.
QFPlib also includes trigonometric functions that are much smaller than the default GCC code. For those, you will have to explicitly call the functions due to the way GCC works. You can find out more details in our online manual: https://imagecraft.com/documentation/jumpstart-c-documentation
Finally, QFPlib also comes in a Cortex-M3 version where the focus is on high-accuracy operations rather than small size. Again, the single checkbox shown above will enable it for -M3/M4/M7 based MCUs.