Libfixmath
| libfixmath | |
|---|---|
| Developer | Ben Brewer |
| Stable release | r64
/ February 2, 2012 |
| Written in | C99 |
| Operating system | Cross-platform |
| Type | fixed-point math library |
| License | MIT |
| Website | code |
| Repository | |
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).[1] 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.[2]
History
libfixmath was developed by Ben Brewer and first released publicly as part of the Dingoo SDK.[3] It has since been used to implement a software 3D graphics library called FGL.[4]
Q16.16 functions
| Name | Description |
|---|---|
fix16_acos |
inverse cosine |
fix16_asin |
inverse sine |
fix16_atan |
one-parameter inverse tangent |
fix16_atan2 |
two-parameter inverse tangent |
fix16_cos |
cosine |
fix16_exp |
exponential function |
fix16_sin |
sine |
fix16_sqrt |
square root |
fix16_tan |
tangent |
fix16_mul |
multiplication |
fix16_div |
division |
fix16_sadd |
saturated addition |
fix16_smul |
saturated multiplication |
fix16_sdiv |
saturated division |
Other functions
| Name | Description |
|---|---|
fix16_to_dbl |
Convert Q16.16 to a double |
fix16_to_float |
Convert Q16.16 to a float |
fix16_to_int |
Convert Q16.16 to an integer |
fix16_from_dbl |
Convert double to a Q16.16 |
fix16_from_float |
Convert float to a Q16.16 |
fix16_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 Float |
|---|---|
| ARM 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.[5]
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
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.