libfixmath is a platform-independent fixed-point math library aimed at developers wanting to perform fast non-integer math on platforms lacking a (or with a low performance) FPU. It offers developers a similar interface to the standard math.h functions for use on Q16.16 fixed-point numbers. libfixmath has no external dependencies other than stdint.h and a compiler which supports 64-bit integer arithmetic (such as GCC). Conditional compilation options exist to remove the requirement for a 64-bit capable compiler as many compilers for microcontrollers and DSPs do not support 64-bit arithmetic.
History libfixmath was developed by Ben Brewer and first released publicly as part of the Dingoo SDK. It has since been used to implement a software 3D graphics library called FGL.
Q16.16 functions Name Descriptionfix16_acos inverse cosinefix16_asin inverse sinefix16_atan one-parameter inverse tangentfix16_atan2 two-parameter inverse tangentfix16_cos cosinefix16_exp exponential functionfix16_sin sinefix16_sqrt square rootfix16_tan tangentfix16_mul multiplicationfix16_div divisionfix16_sadd saturated additionfix16_smul saturated multiplicationfix16_sdiv saturated division
Other functions Name Descriptionfix16_to_dbl Convert Q16.16 to a doublefix16_to_float Convert Q16.16 to a floatfix16_to_int Convert Q16.16 to an integerfix16_from_dbl Convert double to a Q16.16fix16_from_float Convert float to a Q16.16fix16_from_int Convert integer to a Q16.16
Performance For the most intensive function (atan2) benchmark results show the following results:
Name Time Compared to FloatARM Cortex-M0 26.3%Marvell PXA270 (ARM) @ 312 MHz 58.45%Intel T5500 120%Intel Atom N280 141% Note: These results were calculated using fixtest with caching optimizations turned off.
Licensing libfixmath is released under the MIT License, a permissive free software licence, and is free software.
See also
Binary scaling Fixed-point arithmetic Floating-point arithmetic List of open-source mathematical libraries Q (number format)
References
External links Project Page fr_math - Another fixed point math library with variable radix support and tutorials documentation
Group Page/Mailing List