The international standard defining floating-point formats and arithmetic, including single (32-bit) and double (64-bit) precision, rounding, and special values such as infinity and NaN, so results agree across computers.
A binary IEEE 754 number stores a sign bit, a biased exponent field and a fraction, and for normal numbers represents (−1)^sign × 1.fraction × 2^(exponent − bias). Single precision (FP32) uses 1, 8 and 23 bits with a bias of 127; double precision (FP64) uses 1, 11 and 52 bits with a bias of 1023. The leading 1 is implied (the hidden bit), giving 24 and 53 bits of precision, about 7 and 15–16 decimal digits. For example, 1.0 has a stored exponent of 127 and an all-zero fraction, which is 0x3F800000 in FP32.
Special values and exceptions
The extreme exponent codes are reserved. An all-zero exponent encodes ±0 and subnormal numbers, which drop the hidden 1 to fill the gap below the smallest normal value with evenly spaced tiny values (gradual underflow). An all-ones exponent encodes ±infinity when the fraction is zero and NaN (not a number) otherwise. Dividing a nonzero number by zero gives infinity, while 0 ÷ 0 or ∞ − ∞ gives NaN, which compares unequal even to itself. +0 and −0 compare equal but dividing a positive number by +0 gives +∞ and by −0 gives −∞. By default these events set status flags instead of stopping the program.
Rounding and precision limits
The basic operations, including addition, multiplication, division and square root, must be correctly rounded: the result equals the exact value rounded to a representable one. The default mode rounds to nearest with ties to even, which avoids a systematic upward drift. Machine epsilon, the gap above 1.0, is 2⁻²³ (about 1.19 × 10⁻⁷) in FP32 and 2⁻⁵² in FP64, and every integer is exact only up to 2²⁴ and 2⁵³ respectively. Decimal fractions such as 0.1 are not exactly representable, and floating-point addition is not associative, so results should be compared with a tolerance.
Floating point vs. fixed point
Fixed-point numbers have uniformly spaced values, so absolute error is constant and the range is narrow. Floating point keeps the relative error roughly constant across an enormous range, about 10⁻³⁰⁸ to 10³⁰⁸ for FP64, at the cost of more complex hardware for alignment, normalization and rounding. The standard also defines half precision with a 5-bit exponent and a fused multiply-add that rounds only once. Machine-learning hardware often uses bfloat16, which keeps FP32's 8-bit exponent with a 7-bit fraction; it follows the same encoding ideas but is not one of the standard's formats.
A floating-point number represents a normal value as (−1)^sign × 1.significand × 2^exponent and stores three parts: a sign bit for positive or negative, an exponent field for the power of two, and a significand for the significant digits. Because the exponent moves the binary point, the same number of bits covers values from tiny to huge. Splitting into integer and fractional parts is the fixed-point idea, and parity is for error detection.
Single precision (FP32) uses 1 sign bit, 8 exponent bits and 23 significand bits, 32 in total. For normalized numbers the leading 1 of the significand is implied, so precision is 24 bits, about seven decimal digits. Double precision (FP64) uses 1, 11 and 52 bits, with a wider exponent and higher precision. 1, 11, 20 confuses it with double precision's exponent width, and 1, 5, 26 with half precision's.
FAQ
Why does 0.1 + 0.2 not equal 0.3 in floating point?
None of these decimal values has an exact binary representation, so each is stored rounded and the rounding errors do not cancel. In double precision the sum comes out as 0.30000000000000004, so equality tests should use a tolerance.
What is the exponent bias in IEEE 754 single precision?
The bias is 127, so the true exponent is the stored 8-bit value minus 127. Stored values 0 and 255 are reserved for zero, subnormals, infinity and NaN, leaving 1–254 for normal numbers.
Why is NaN not equal to itself?
IEEE 754 defines every comparison involving NaN as unordered, so x == x is false when x is NaN. Use a dedicated function such as isnan rather than relying on this trick.
Questions that mention IEEE 754 (12)
IEEE 754 appears in 14 practice questions across 1 topic, including Computer Arithmetic.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.