Lite / Independent Engineering Research / Week 24
Reduced precision: range, resolution and error
Your filter works perfectly in Python floats. On the 16-bit chip, it slowly drifts and then explodes. What went wrong?
Why should I care?
Reduced precision saves memory, time and energy, but every bit you remove costs either range (you overflow) or resolution (you round). The art is spending bits where the signal needs them, and proving with a measurement that the result still meets the requirement.
- Choose a fixed-point format (Qm.n) from a signal's range and the resolution needed.
- Explain overflow, rounding and accumulation of error in reduced-precision arithmetic.
- Measure accuracy loss from reduced precision or sample rate against a stated requirement.
Predict
A signed 4-bit register holds 7 (0111). You add 1. What does it hold?
- 8
- −8
- 0
- 7 (it saturates)
Guess first, then reveal
0111 + 1 = 1000, which in 4-bit two's complement is −8: it wraps. Some DSP hardware saturates to 7 instead; plain integer adders wrap. Either way, the true answer 8 cannot be represented.
Discover
On the 4-bit register, show the largest and smallest values, then add 1 to 1111 and watch the carry fall off. Now imagine those 4 bits as Q1.3 fixed point (one integer bit, three fraction bits): what are its range and step size?
What the interactive shows (text version)
The 4-bit register shows 0000 to 1111. In two's complement, 0111 is 7 and adding 1 gives 1000, which is −8: the value wraps. Read as Q1.3, the same bits cover −1 to 0.875 in steps of 0.125.
Understand
Qm.n formats
A signed Qm.n number has m integer bits (including sign) and n fraction bits: value = integer / 2ⁿ. Range ≈ [−2^(m−1), 2^(m−1)), step 2^(−n). Q1.15 in 16 bits covers [−1, 1) in steps of about 3×10⁻⁵. Choose m from the largest value the signal (and every intermediate result) can reach, then give the rest to n.
Where precision is lost
Rounding each result loses up to half a step. Multiplication doubles the fraction bits (Q1.15 × Q1.15 = Q2.30), so results are shifted back and rounded. Accumulation of many products needs extra headroom bits. Feedback (recursive filters, integrators) can accumulate rounding errors or sustain small oscillations (limit cycles).
Precision is a measured requirement
State the requirement first (for example, 'error under 0.5% of full scale'), then implement at candidate precisions on identical inputs, measure the error and pick the smallest that meets it with margin. The same applies to sample rate: lower rates save energy until aliasing or lag breaks the requirement. This is the method of the term project.
Explain it another way
Intuitive
A ruler marked only in centimetres can't measure a hair, and a 30 cm ruler can't measure a room. Fixed point makes you pick your ruler before you start.
Technical
Fixed-point DSP uses integer ALUs with shifts for scaling, saturating arithmetic options, and wide accumulators (for example 40-bit on 16-bit DSPs) to avoid overflow in sums.
Mathematical
Quantisation noise of step Δ has variance Δ²/12. For Q1.15, Δ = 2⁻¹⁵, so RMS ≈ 8.8×10⁻⁶. A sum of N products, each rounded, has error variance about N·Δ²/12, so RMS error grows like √N.
Applied
Audio codecs, motor-control loops and many sensor filters on microcontrollers run in Q15 or Q31 arithmetic because integer instructions are faster and cheaper in energy than floating point on chips without an FPU.
Worked example 1
A gyro reads ±250 °/s and you need 0.01 °/s resolution. Pick a 16-bit signed format.
Range needs 2^(m−1) ≥ 250, so m − 1 = 8 integer bits plus sign: m = 9. That leaves n = 7 fraction bits: step 1/128 ≈ 0.0078 °/s < 0.01 ✓. Q9.7.
Common mix-ups
More fraction bits are always better.
✓ In a fixed word, every fraction bit is taken from range: you trade overflow risk for resolution.If the inputs fit, the result fits.
✓ Sums and products need more bits than their inputs; size every intermediate, or use a wide accumulator.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Start the term project: pick your algorithm, write the accuracy requirement and decision rule, and choose Q formats for a 16-bit and an 8-bit version with the range and resolution reasoning written out. Do not run anything yet.
Reflect
Where in your earlier projects did a number silently overflow or round, and how would you have caught it?
Write your answer on paper or in your own notes. Lite never stores what you write.