Nepedia
Back to Discover
Advanced Reader
🔢

Floating-point arithmetic

math Maturity 7-9 Next article →

Floating-point arithmetic is a method used by computers to represent and calculate real numbers. In mathematics, numbers can be incredibly vast or microscopically small. A computer might need to measure the distance between distant galaxies or the tiny space between protons in an atom.

Float example
Float example

Because computers have limited memory, they cannot store every possible digit of every number. Floating-point arithmetic solves this by using a system of approximation. This allows a computer to handle a huge dynamic range of values while maintaining fast processing speeds.

To understand how this works, think of scientific notation. A floating-point number is logically composed of two distinct parts: the significand and the exponent. The significand, also called the mantissa or coefficient, is a signed string of digits. The length of this significand determines the precision of the number. The exponent is a signed integer that modifies the magnitude of the number.

FloatingPointPrecisionAugmented
FloatingPointPrecisionAugmented

The exponent tells the computer where to place the radix point, which is the dot used to separate whole numbers from fractions. By changing the exponent, the radix point can "float" to different positions, which gives the system its name.

In practice, the computer calculates the value by multiplying the significand by the base raised to the power of the exponent. Most modern computers use base two, or binary, though some use base ten, known as decimal floating point. If the exponent is positive, the radix point shifts to the right, creating a larger number. If the exponent is negative, the point shifts to the left, creating a smaller number. This mechanism allows the same number of digits to represent vastly different orders of magnitude.

Float example
Float example

Because the significand has a fixed length, the system cannot always represent a number perfectly. For example, the fraction 1/3 results in an infinite string of repeating digits in both decimal and binary. If a math operation produces a result with more digits than the system allows, the computer must use rounding. It identifies the nearest representable floating-point number to complete the calculation. This means that floating-point numbers are not uniformly spaced on a number line. The gap between two consecutive numbers changes depending on the value of the exponent.

A number line representing single-precision floating point's numbers and numbers that it cannot display
A number line representing single-precision floating point's numbers and numbers that it cannot display

The history of these ideas stretches back over a century. In 1914, the Spanish engineer Leonardo Torres Quevedo published an analysis of floating point based on the concept of an analytical engine.

Quevedo 1917
Quevedo 1917

As computing technology advanced, the need for a universal standard became clear. In 1985, the IEEE 754 Standard for Floating-Point Arithmetic was established. Since the 1990s, the most common computer representations have followed these IEEE standards. This standardization ensures that different computers can perform math in a consistent way.

Performing these complex calculations requires significant computational power. Some systems use software implementations, often called "softfloat," to handle the math. However, most modern computers include a dedicated hardware component called a Floating-Point Unit, or FPU. These are sometimes called math coprocessors because they are specially designed for these operations.

Z3 Deutsches Museum
Z3 Deutsches Museum

The speed of these operations is a critical metric for high-performance computers. This speed is commonly measured in FLOPS, which stands for floating-point operations per second. This measurement is vital for applications that require intensive mathematical modeling.

While floating-point arithmetic is the most common method, other systems exist for specific needs. Fixed-point representation uses a set position for the radix point, which is often used in simpler embedded processors. There are also logarithmic number systems, which represent numbers using their logarithms. Some specialized software uses rational arithmetic to represent numbers as exact fractions, avoiding the need for approximation entirely. Even so, floating-point arithmetic remains the standard for most general-purpose computing due to its unique balance of speed and range.

625 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (8)
File:Z3 Deutsches Museum.JPG
Z3 Deutsches Museum.JPG
File:A number line representing single-precision floating point's numbers and numbers that it cannot display.png
A number line representing...
File:FloatingPointPrecisionAugmented.png
FloatingPointPrecisionAugmented.png
File:Quevedo 1917.jpg
Quevedo 1917.jpg
File:Konrad Zuse (1992).jpg
Konrad Zuse (1992).jpg
File:William Kahan 2008.jpg
William Kahan 2008.jpg
File:Float example.svg
Float example.svg
File:Resistors in Parallel.svg
Resistors in Parallel.svg
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.