Floating-Point Arithmetic
Also known as: Floating point, IEEE 754 arithmetic
Method of representing and calculating with real numbers in binary using a significand and an exponent, trading exactness for a vast range.
Floating-point arithmetic is how most computers handle numbers with fractional parts. A floating-point number is stored like scientific notation in base 2: a sign, a significand holding the significant digits and an exponent that scales it, so the same format can represent both the width of an atom and the distance between galaxies. The common 64-bit double-precision format uses 1 sign bit, 11 exponent bits and 52 fraction bits, giving roughly 15 to 17 significant decimal digits. Because only finitely many values fit, most real numbers must be rounded to the nearest representable one.
Before standardization, manufacturers implemented floating point differently, so the same program could give different answers on different machines. The IEEE 754 standard, first published in 1985 and revised in 2008 and 2019, fixed formats, rounding rules and special values such as positive and negative infinity and NaN, meaning not a number, used for undefined results such as zero divided by zero. William Kahan, the principal architect of the standard, received the Turing Award in 1989 in part for this work. Most general-purpose processors implement IEEE 754 formats in hardware.
Rounding produces results that surprise beginners. In binary, 0.1 cannot be represented exactly, so adding 0.1 and 0.2 gives a value slightly different from 0.3, and testing floating-point numbers for exact equality is usually a mistake. Errors can accumulate over long calculations or be magnified by subtracting nearly equal numbers. For money, where exact decimal results matter, programs use integers or decimal types instead. In machine learning, by contrast, reduced-precision formats of 16 bits or fewer are popular on GPUs, because neural networks tolerate imprecision and lower precision saves memory and energy, an idea related to quantization.
Key points
- Floating-point numbers store a sign, significand and exponent, covering a huge range with limited precision.
- IEEE 754, first published in 1985, standardized formats, rounding and special values such as infinity and NaN.
- Many decimal fractions, such as 0.1, cannot be represented exactly in binary floating point.
- Financial software uses integers or decimal types instead, while machine learning often uses reduced-precision floats.
Related entries
Binary Number System
Base-2 positional number system that represents values using only the digits 0 and 1, the foundation of how digital computers store data.
Quantization
Technique that stores and computes a model's numbers at lower precision, such as 8 or 4 bits, to cut memory use and speed up inference.
Graphics Processing Unit
Highly parallel processor originally designed to render images, now also widely used for scientific computing and for training and running AI models.
Central Processing Unit
Main processor of a computer, which fetches, decodes and executes program instructions and coordinates the operation of other components.
Machine Learning
Branch of artificial intelligence in which computer systems improve at tasks by learning patterns from data rather than following explicitly programmed rules.
JavaScript
High-level programming language of the web, created at Netscape in 1995, that runs in every major browser and on servers through runtimes like Node.js.
JSON
Lightweight, text-based data interchange format that represents structured data as nested objects and arrays, derived from JavaScript syntax.
Referenced by
Other entries that discuss or point to Floating-Point Arithmetic.