Learn fixed-point arithmetic from first principles.
When floating-point isn't an option, you need to know this.
Floating-point arithmetic is convenient but problematic:
- Non-deterministic — results vary across platforms (x87 vs SSE vs ARM)
- Accumulation drift — small errors compound over time
- Certification challenges — hard to prove bounds for safety-critical systems
Fixed-point gives you:
- Bit-identical results — same answer on every platform, every time
- Bounded errors — you know exactly how wrong you can be
- No special hardware — just integers, which every CPU handles identically
Core Principle: Prove first, code second.
| Lesson | Topic | What You'll Learn |
|---|---|---|
| 00 | Why Not Float? | Real failures, why IEEE 754 surprises you |
| 01 | The Model | Q notation, representation, range vs precision |
| 02 | Arithmetic | Add, subtract, multiply, divide — done right |
| 03 | Safety | Handling the edges without undefined behaviour |
| 04 | Rounding | Truncation, round-half-up, round-to-nearest-even |
| 05 | Conversion | Moving between representations safely |
| 06 | Patterns | PID controllers, filters, accumulators |
| 07 | Strategy | Decision framework for real projects |
Each lesson includes working C99 code you can compile and run.
git clone https://github.com/SpeyTech/fixed-point-fundamentals.git
cd fixed-point-fundamentals
makeEach lesson is self-contained. Start with lesson 00, or jump to what you need.
Prerequisites: C programming, basic arithmetic, a C compiler. No external dependencies.
- Embedded engineers moving from floating-point to fixed-point
- ML deployment engineers targeting hardware without FPUs
- Safety-critical developers needing deterministic arithmetic
- Anyone who's been bitten by floating-point "surprises"
- Q Format Reference — common formats and their properties
- Common Pitfalls — mistakes to avoid
- Further Reading — where to go next
This course teaches concepts with standalone, copy-paste-friendly code.
For production safety-critical systems, certifiable-inference provides bit-identical inference across platforms, Merkle audit trails, and DO-178C / IEC 62304 / ISO 26262 alignment.
Learn the fundamentals here. Build certified systems there.
Articles exploring these concepts in depth:
- Fixed-Point Neural Networks: The Math Behind Q16.16 — how integer arithmetic enables deterministic AI
- Round-to-Nearest-Even: The Rounding Mode That Makes Determinism Possible — why banker's rounding matters
- Why Floating Point Is Dangerous — when 'mostly reproducible' isn't good enough
- Bit-Perfect Reproducibility: Why It Matters and How to Prove It — what deterministic execution actually means
- c-from-scratch — Safety-critical C from first principles
- certifiable-inference — Production fixed-point ML inference
- C-Sentinel — Semantic security monitoring
MIT — use it however you like.
"Fixed-point is not a limitation. It's a commitment to correctness."
William Murray — SpeyTech
Building deterministic systems in the Scottish Highlands.
If even one person finds this useful, it was worth writing.