Implement Saturating Q15 Fixed-Point Multiply and Add
Last updated: November 29, 2026
Quick Overview
Write Q15 fixed-point helpers for a DSP library: convert floats to Q15, add with saturation, and multiply with rounding and saturation, matching what a Cortex-M saturating instruction would produce.
Arm
November 29, 20260
0
0 solved
Write Q15 fixed-point helpers for a DSP library: convert floats to Q15, add with saturation, and multiply with rounding and saturation, matching what a Cortex-M saturating instruction would produce.
CMSIS-DSP and CMSIS-NN run on Cortex-M parts without floating-point units, so Arm's embedded software teams work in Q15 and Q31 constantly. The interviewer checks you understand the number format, rounding, and the single overflow case that trips people up.
What the Interviewer Expects
- Explain Q15: 16-bit signed, value = integer / 32768, range [-1, 1)
- Multiply to Q30 then shift right by 15
- Add half an LSB before shifting to round
- Saturate to [-32768, 32767] including the -1 times -1 case
- Relate to Arm instructions such as QADD16, SSAT, SQRDMULH
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Why does -1.0 times -1.0 overflow, and is that the only overflow case for multiply?
- How would you vectorise this with Helium (MVE) or Neon?
- When would you choose Q31 over Q15, or fall back to float?
- How does rounding bias accumulate in a long FIR filter?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Q15 stores a real number x in a 16-bit signed integer as round(x * 2^15). Representable range is -1.0 to 1 - 2^-15. Provide to_q15, q15_add, q15_mul, all saturating rather than wrapping, becau...
High-Level Design
- Add: two Q15 values add directly, then clamp.
- Multiply: the integer product is Q30 (scale 2^30). Shifting right by 15 brings it back to Q15. Adding
1 << 14first rounds to nearest instead of alw...