This is a mirror of the libfixmath's original SVN repository on Google Code.
Not actively maintained, pull requests welcome.
Libfixmath implements Q16.16 format fixed point operations in C.
License: MIT
Configuration options are compile definitions that are checked by the preprocessor with #ifdef
and #ifndef
. All of these are undefined by default.
#ifndef
: Most accurate version, accurate to ~2.1%.#ifdef
: Fast implementation, runs at 159% the speed of above 'accurate' version with a slightly lower accuracy of ~2.3%.
#ifndef
: For compilers/platforms that haveuint64_t
.#ifdef
: For compilers/platforms that do not haveuint64_t
.
#ifndef
: Use static memory caches for exponents (32KB) and trigonometry (80KB).#ifdef
: Do not use caches.
Note: will be automatically defined if FIXMATH_OPTIMIZE_8BIT
is defined.
#ifndef
: For platforms that have hardware integer division.#ifdef
: For platforms that do not have hardware integer division.
#ifndef
: Check for overflow and return the overflow constants.#ifdef
: Do not check for overflow.
#ifndef
: Use rounding.#ifdef
: Do not use rounding.
#ifndef
: Do not optimize for processors with 8-bit multiplication like Atmel AVR.#ifdef
: Optimize for processors like Atmel AVR. Also definesFIXMATH_NO_HARD_DIVISION
automatically infix16.h
.
The simplest way to use libfixmath
as a dependency is with CMake's FetchContent API.
include(FetchContent)
FetchContent_Declare(
libfixmath
GIT_REPOSITORY https://github.com/PetteriAimonen/libfixmath.git
GIT_TAG <the long git hash of the version you want>
)
FetchContent_MakeAvailable(libfixmath)
target_compile_definitions(libfixmath PRIVATE
# FIXMATH_FAST_SIN
# FIXMATH_NO_64BIT
# FIXMATH_NO_CACHE
# FIXMATH_NO_HARD_DIVISION
# FIXMATH_NO_OVERFLOW
# FIXMATH_NO_ROUNDING
# FIXMATH_OPTIMIZE_8BIT
)
target_link_libraries(my_cmake_project PRIVATE libfixmath)