Main Page | See live article | Alphabetical index

Fixed point

In mathematics, a fixed point of a function is a point that is mapped to itself by the function. For example, if f is defined on the real numbers by f(x) = x2 − 3x + 4, then 2 is a fixed point of f, because f(2) = 2.

See also

In computing, a fixed-point number representation is a real data type for a number that has a fixed number of digits after the decimal (or binary or hexadecimal) point. For example, a fixed-point number with 4 digits after the decimal point could be used to store numbers such as 1.3467, 281243.3234 and 0.1000, but would round 1.0301789 to 1.0302 and 0.0000654 to 0.0001.

As long as the numeric value uses only the number of digits specified after the decimal point, fixed-point values can exactly represent all values up to its maximum value (determined by the number of bits in its representation). This is in contrast to floating-point representations, which include an automatically-managed exponent but cannot represent as many digits accurately (given the same number of bits in its representation).

A common use for fixed-point numbers is for storing monetary values, where the "inexact" values of floating-point numbers are often a liability. Fixed-point representations are also sometimes used if either the executing processor does not have any floating point unit (FPU) or if fixed-point provides an improved performance necessary for an application. Historically, fixed-point representations were the norm for decimal data types (for example, in PL/I or COBOL). The Ada programming language includes built-in support for both fixed-point and floating-point.

Many computer languages do not include built-in support for floating point values, because for most applications, floating-point representations are fast enough and accurate enough. Floating-point representations are more flexible than fixed-point representations, because they can handle a wider dynamic range. Floating-point representations are also slightly easier to use, because they do not require programmers to specify the number of digits after the decimal point.

However, if they are needed, fixed-point numbers can be implemented even in programming languages like C and C++ that do not include such support built-in.

Here are some high-profile uses of fixed-point representations:

  1. GnuCash is an application for tracking money. It is written in C and switched from a floating-point representation of money to a fixed-point implementation as of version 1.6. This change was made to avoid the potential rounding errors of floating-point representations.
  2. Tremor is a software library that decodes the Ogg Vorbis audio format. Tremor uses fixed-point because many audio decoding hardware devices do not have an FPU (to save money) and audio decoding requires enough performance that a software implementation of floating-point on low-speed devices would not work well.

External Links: