Fixed-Point Numbers & Binary Fractions: Representation and Conversion
Fixed-Point Numbers & Binary Fractions: Representation and Conversion
This page explains fixed-point numbers, how fractions are represented in binary, and how to convert between decimal and binary fixed-point notation.
Fixed-point idea
Fixed-point numbers are used to represent fractional values when floating-point hardware is unavailable or unnecessary. The idea: reserve part of the bits for the integer part and part for the fractional part. The position of the binary (or decimal) point is fixed — hence the name.
Example: If we decide that 8 bits are used for the integer part and 8 bits for the fractional part, the 16-bit pattern 00000011 10000000₂ represents 3.5 (3 + 1/2).
Decimal analogy
In decimal notation, 543.125 can be written as:
543.125 = 5 × 10² + 4 × 10¹ + 3 × 10⁰ + 1 × 10⁻¹ + 2 × 10⁻² + 5 × 10⁻³
The same principle works in binary, except that the base is 2 instead of 10.
Binary fixed-point representation
To represent 543.125₁₀ in binary:
1. Convert the integer part (543) to binary: 543 ÷ 2 → 1000011111₂
2. Convert the fractional part (0.125) to binary by multiplying by 2 until 0: 0.125 × 2 = 0.25 → 0 0.25 × 2 = 0.5 → 0 0.5 × 2 = 1.0 → 1 Result: 0.001₂
3. Combine both: 543.125 = 1000011111.001₂
The binary point separates integer and fractional parts. It is not stored in hardware — its position is defined by the data format.
Conversion method
To convert a fractional decimal number to binary:
1. Separate integer and fractional parts. 2. Convert the integer part by repeated division by 2 (recording remainders). 3. Convert the fractional part by repeated multiplication by 2 (recording the integer parts). 4. Combine the two results.
Example: 13.625 Integer: 13 → 1101₂ Fractional: 0.625 × 2 = 1.25 → 1 0.25 × 2 = 0.5 → 0 0.5 × 2 = 1.0 → 1 Fractional = .101₂ Final: 13.625 = 1101.101₂
Rational and irrational numbers
A rational number (ℚ) can always be expressed as a fraction p/q. In any base, its representation is either finite or repeating. An irrational number (e.g., π, √2) has a non-repeating infinite expansion.
Example:
- 1/3 = 0.333… in base 10, infinite repeating.
- 0.1₁₀ = 0.0001100110011…₂ in binary, also repeating.
Finite and periodic binary fractions
Some decimal fractions cannot be represented exactly in binary because their denominators contain factors other than 2. For example:
- 1/10 (0.1₁₀) cannot be written finitely in binary.
- 1/8 = 0.001₂ can be written exactly.
Rule: A fraction u/v (in simplest terms) has a finite representation in base b only if v has no prime factors other than those in b.
Why fixed-point matters
- Useful for embedded systems without floating-point hardware.
- Ideal for representing currency or measurements with fixed precision.
- Offers predictable rounding and exact arithmetic for limited ranges.