What Is IEEE 754?
IEEE 754 is a standard for representing and working with floating-point numbers in computing systems.
Unlike integers, floating-point numbers need to represent values with fractional parts and a wide range of magnitudes. IEEE 754 formats achieve this by dividing a binary representation into a sign field, an exponent field and a fraction field.
Two commonly used formats are binary32, often called single precision, and binary64, commonly called double precision.
Floating-point representation is not the same as exact decimal arithmetic. Some decimal fractions cannot be represented precisely using a finite number of binary bits. The closest representable value is stored instead.
Understanding Sign, Exponent and Fraction Bits
A normal finite binary floating-point number is interpreted using:
Here, fraction means the fractional binary value encoded in the fraction field.
This formula applies to normal values. Subnormal numbers, zero, infinity and NaN require different interpretation.
Sign
The sign bit determines whether the represented value is positive (0) or negative (1).
Exponent
The exponent field determines the scale of the number through an unsigned biased power of two.
Fraction
The fraction field stores the significant fractional bits. Normal numbers also have an implicit leading 1.
IEEE 754 Single Precision — 32 Bits
Binary32 uses 32 bits arranged into three fields:
| Field | Bits |
|---|---|
| Sign | 1 |
| Exponent | 8 |
| Fraction | 23 |
| Total | 32 |
The exponent bias is 127.
Binary32 has approximately seven significant decimal digits of precision, although exact accuracy depends on the value.
IEEE 754 Double Precision — 64 Bits
Binary64 uses 64 bits arranged into three fields:
| Field | Bits |
|---|---|
| Sign | 1 |
| Exponent | 11 |
| Fraction | 52 |
| Total | 64 |
The exponent bias is 1023.
Binary64 typically provides approximately 15–17 significant decimal digits.
Using more bits provides greater precision and a wider exponent range, but it does not make every decimal fraction exactly representable.
Step-by-Step IEEE 754 Conversion
Worked Example: Convert 13.25 to IEEE 754 Binary32
Start with decimal: 13.25
Convert the integer part: 13 = 1101 in binary.
Convert the fractional part: 0.25 = 0.01 in binary.
Combine them: 13.25 = 1101.01
Normalize: 1.10101 × 2³
The number is positive, so: Sign = 0
The exponent is 3. Add the binary32 bias: 3 + 127 = 130
130 in binary: 10000010
The fractional bits after the leading 1 are: 10101
Pad the fraction field to 23 bits: 10101000000000000000000
Final Representation
Hexadecimal: 41540000
This example is exactly representable because 0.25 is a power-of-two fraction.
Why Decimal Fractions Sometimes Change
Consider decimal 0.1.
It looks simple in base 10, but its binary fractional representation repeats indefinitely.
A 32-bit floating-point format cannot store every repeating bit, so it rounds the value to the nearest representable binary32 number under the normal round-to-nearest rule.
For positive 0.1, the binary32 hexadecimal encoding is: 3DCCCCCD
The corresponding stored value is approximately: 0.10000000149011612
In binary64, the hexadecimal representation is: 3FB999999999999A
This does not mean the computer is randomly changing numbers. It is a consequence of finite binary precision.
When comparing floating-point calculations, the appropriate tolerance depends on the problem. Exact equality is not always the right test for values produced through arithmetic.
Special IEEE 754 Values
Positive and Negative Zero
IEEE 754 distinguishes +0 and -0 using the sign bit. They compare equal in many ordinary numeric comparisons, but their sign can affect certain operations such as 1 / (-0) producing negative infinity.
Subnormal Numbers
Subnormal numbers represent very small nonzero magnitudes near zero. They use an exponent field of all zeros and do not have the implicit leading 1 used by normal numbers.
Infinity
Positive and negative infinity use an exponent field containing all ones and a fraction field containing all zeros.
NaN
NaN means Not a Number. NaN values have an exponent field of all ones and a nonzero fraction field. More than one bit pattern represents NaN.
Common IEEE 754 Conversion Mistakes
Forgetting the exponent bias: The stored exponent is not the same as the unbiased exponent. Remember to add 127 for binary32 or 1023 for binary64.
Assuming the leading 1 is explicitly stored: For normal binary32 and binary64 values, the leading 1 is implicit and not written into the fraction bits.
Treating decimal fractions as exactly representable: Values such as 0.1 usually require rounding because of infinite binary fractional expansion.
Applying the normal-number formula to subnormal values: Subnormal numbers use a different significand rule without the implicit leading 1.
Losing the sign of negative zero: Negative zero has a distinct bit pattern with the sign bit set to 1.
Frequently Asked Questions
What is the difference between 32-bit and 64-bit IEEE 754?
Binary64 uses more exponent and fraction bits, allowing a wider range of magnitudes and greater numerical precision than binary32.
Why is 0.1 not stored exactly?
Because 0.1 has an infinitely repeating binary fractional expansion. A finite binary32 or binary64 representation must approximate it.
What does the exponent bias do?
It allows the exponent field to encode negative and positive exponents using an unsigned stored value.
Can IEEE 754 represent infinity?
Yes. Both positive and negative infinity have dedicated encodings with all-ones in the exponent field and all-zeros in the fraction field.
Does IEEE 754 have only one NaN value?
No. Multiple bit patterns represent NaN, depending on the fraction field payload and signaling bits.
Related Educational Tools
Explore companion calculators and converters for digital logic design, computer architecture, and number systems.
Number System Converter
Convert integers between binary, octal, decimal, and hexadecimal using positional place values and repeated division.
Gray Code Converter
Convert between binary and binary reflected Gray code with bit-by-bit XOR steps, rules, and reference tables.
Karnaugh Map Solver
Simplify 2–5 variable Boolean logic functions with step-by-step visual K-Maps, SOP/POS forms, and circuit diagrams.
