# Fixed-point arithmetic

(Redirected from Fixed-point)

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.

Fixed-point can exactly represent decimal fractions while still employing the base 2 arithmetic that is efficient in most of today's computers. Most floating point representations in computers use base 2 values, which cannot exactly represent most fractions that are easily represented in base 10. For example, one-tenth (.1) and one-hundredth (.01) can be represented only approximately by base-2 floating point representations, while they can be represented exactly in fixed-point representations — one simply stores the data values multiplied by the appropriate power of 10.

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.

Very few computer languages include built-in support for fixed 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 examples of fixed-point representations still in common use:

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 and Toast are software libraries that decode the Ogg Vorbis and GSM Full Rate audio formats respectively. These codecs use fixed-point arithmetic 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 produce output in real time.
3. All 3D graphics engines on Sony's original PlayStation and Nintendo's Game Boy Advance and Nintendo DS video game systems use fixed-point arithmetic for the same reason as Tremor and Toast: to gain throughput on an architecture without an FPU.

• Art and Cultures
• Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
• Space and Astronomy