Libfixmath

Last updated
libfixmath
Developer(s) Ben Brewer
Stable release
r64 / February 2, 2012;10 years ago (2012-02-02)
Repository
Written in C99
Operating system Cross-platform
Type fixed-point math library
License MIT
Website code.google.com/p/libfixmath   OOjs UI icon edit-ltr-progressive.svg

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]

Contents

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

NameDescription
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

NameDescription
fix16_to_dblConvert Q16.16 to a double
fix16_to_floatConvert Q16.16 to a float
fix16_to_intConvert Q16.16 to an integer
fix16_from_dblConvert double to a Q16.16
fix16_from_floatConvert float to a Q16.16
fix16_from_intConvert integer to a Q16.16

Performance

For the most intensive function (atan2) benchmark results show the following results:

NameTime Compared to Float
ARM Cortex-M0 26.3%
Marvell PXA270 (ARM) @ 312 MHz58.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

Related Research Articles

<span class="mw-page-title-main">Floating-point arithmetic</span> Computer approximation for real numbers

In computing, floating-point arithmetic (FP) is arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. For example, 12.345 can be represented as a base-ten floating-point number:

MIPS is a family of reduced instruction set computer (RISC) instruction set architectures (ISA) developed by MIPS Computer Systems, now MIPS Technologies, based in the United States.

<span class="mw-page-title-main">Floating-point unit</span> Part of a computer system

A floating-point unit is a part of a computer system specially designed to carry out operations on floating-point numbers. Typical operations are addition, subtraction, multiplication, division, and square root. Some FPUs can also perform various transcendental functions such as exponential or trigonometric calculations, but the accuracy can be very low, so that some systems prefer to compute these functions in software.

<span class="mw-page-title-main">MMX (instruction set)</span> Instruction set designed by Intel

MMX is a single instruction, multiple data (SIMD) instruction set architecture designed by Intel, introduced on January 8, 1997 with its Pentium P5 (microarchitecture) based line of microprocessors, named "Pentium with MMX Technology". It developed out of a similar unit introduced on the Intel i860, and earlier the Intel i750 video pixel processor. MMX is a processor supplementary capability that is supported on IA-32 processors by Intel and other vendors as of 1997.

In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.

<span class="mw-page-title-main">Windows API</span> Microsofts core set of application programming interfaces on Windows

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations that are often referred to by their own names ; see the versions section. Almost all Windows programs interact with the Windows API. On the Windows NT line of operating systems, a small number use the Native API.

SuperWaba is a discontinued Java-like virtual machine (VM) that targets portable devices. Software developers use application programming interfaces (APIs), accessed through associated libraries and small tools, to create applications that can run within the VM on supported platforms.

In computing, fixed-point is a method of representing fractional (non-integer) numbers by storing a fixed number of digits of their fractional part. Dollar amounts, for example, are often stored with exactly two fractional digits, representing the cents. More generally, the term may refer to representing fractional values as integer multiples of some fixed small unit, e.g. a fractional amount of hours as an integer multiple of ten-minute intervals. Fixed-point number representation is often contrasted to the more complicated and computationally demanding floating-point representation.

<span class="mw-page-title-main">GNU Multiple Precision Arithmetic Library</span> Free software

GNU Multiple Precision Arithmetic Library (GMP) is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers. There are no practical limits to the precision except the ones implied by the available memory (operands may be of up to 232−1 bits on 32-bit machines and 237 bits on 64-bit machines). GMP has a rich set of functions, and the functions have a regular interface. The basic interface is for C, but wrappers exist for other languages, including Ada, C++, C#, Julia, .NET, OCaml, Perl, PHP, Python, R, Ruby, and Rust. Prior to 2008, Kaffe, a Java virtual machine, used GMP to support Java built-in arbitrary precision arithmetic. Shortly after, GMP support was added to GNU Classpath.

<span class="mw-page-title-main">C99</span> C programming language standard, 1999 revision

C99 is an informal name for ISO/IEC 9899:1999, a past version of the C programming language standard. It extends the previous version (C90) with new features for the language and the standard library, and helps implementations make better use of available computer hardware, such as IEEE 754-1985 floating-point arithmetic, and compiler technology. The C11 version of the C programming language standard, published in 2011, replaces C99.

In computer architecture, 128-bit integers, memory addresses, or other data units are those that are 128 bits wide. Also, 128-bit central processing unit (CPU) and arithmetic logic unit (ALU) architectures are those that are based on registers, address buses, or data buses of that size.

<span class="mw-page-title-main">Integer overflow</span> Computer arithmetic error

In computer programming, an integer overflow occurs when an arithmetic operation attempts to create a numeric value that is outside of the range that can be represented with a given number of digits – either higher than the maximum or lower than the minimum representable value.

Extended precision refers to floating-point number formats that provide greater precision than the basic floating-point formats. Extended precision formats support a basic format by minimizing roundoff and overflow errors in intermediate values of expressions on the base format. In contrast to extended precision, arbitrary-precision arithmetic refers to implementations of much larger numeric types using special software.

<span class="mw-page-title-main">CUDA</span> Parallel computing platform and programming model

CUDA is a parallel computing platform and application programming interface (API) that allows software to use certain types of graphics processing units (GPUs) for general purpose processing, an approach called general-purpose computing on GPUs (GPGPU). CUDA is a software layer that gives direct access to the GPU's virtual instruction set and parallel computational elements, for the execution of compute kernels.

<span class="mw-page-title-main">GLBasic</span> Commercial BASIC programming language

GLBasic is a commercial BASIC programming language that can compile to various platforms including Windows, Linux, Mac OS X, and some handheld devices. The language is designed to be simple and intuitive.

In computing, quadruple precision is a binary floating point–based computer number format that occupies 16 bytes with precision at least twice the 53-bit double precision.

In computer software and hardware, find first set (ffs) or find first one is a bit operation that, given an unsigned machine word, designates the index or position of the least significant bit set to one in the word counting from the least significant bit position. A nearly equivalent operation is count trailing zeros (ctz) or number of trailing zeros (ntz), which counts the number of zero bits following the least significant one bit. The complementary operation that finds the index or position of the most significant set bit is log base 2, so called because it computes the binary logarithm ⌊log2(x)⌋. This is closely related to count leading zeros (clz) or number of leading zeros (nlz), which counts the number of zero bits preceding the most significant one bit. There are two common variants of find first set, the POSIX definition which starts indexing of bits at 1, herein labelled ffs, and the variant which starts indexing of bits at zero, which is equivalent to ctz and so will be called by that name.

Dart is a programming language designed for client development, such as for the web and mobile apps. It is developed by Google and can also be used to build server and desktop applications.

Absoft Fortran Compilers are set of Fortran compilers for Microsoft Windows, Apple Macintosh, and Linux produced by Absoft Corporation. The compilers are source code compatible across platforms.

RISC-V is an open standard instruction set architecture (ISA) based on established RISC principles. Unlike most other ISA designs, RISC-V is provided under open source licenses that do not require fees to use. A number of companies are offering or have announced RISC-V hardware, open source operating systems with RISC-V support are available, and the instruction set is supported in several popular software toolchains.

References

  1. "libfixmath Project Page".
  2. "64-bit Compiler Support Issues".
  3. "Dingoo SDK Project Page".
  4. "FGL Flatmush/Fixed-Point Graphics Library Project Page".
  5. "fixtest Download Page".