Source: https://mokxi.com/teachers/plans/fixed-point-math
Updated: 2026-11-19

Lesson plan

# Fixed-point and integer math lesson plan

Fractions without a float unit, on an Uno and a knob: what floats really cost, Q formats, scaling, overflow guards, tables and fast trig. Ends with a fixed-point filter you tune and measure.

4 chapters, 7 lessons, about 5 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- Time what a float costs, then keep fractions in integers on purpose.
- Scale a knob to millivolts, and guard every sum against overflow.
- Work it out once and look it up: gamma curves and a quarter-wave sine.
- A fixed-point filter on a noisy knob, measured and tuned.

### Materials for the whole unit

- Arduino Uno R3
- Full-size breadboard
- LED
- Potentiometer
- Resistor

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 25 min

## Floats and Q numbers

Time what a float costs, then keep fractions in integers on purpose.

Lesson | Time | What students do

Why floats cost The Uno has no floating-point hardware. Time int, long and float multiplies with micros(), take off the loop overhead, and find where a float runs out of bits. | 40 min

- Run it: a thousand multiplies
- Take off the loop
- Out of bits at 16777216
- Ten dimes
- Now time a divide

Q formats Fractions stored in plain integers: Q8.8 in an int16_t, printing one with integers only, multiply then shift, divide with the shift first, and trading range for precision. | 45 min

- Run it: pi in an integer
- What a Q number can hold
- Multiply, then shift
- Divide: shift first
- Trade range for precision
- Negative numbers too

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED
- Potentiometer
- Resistor

### Check for understanding

Each student finishes "Q formats" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Negative numbers too".

Chapter 2. About 1 h 20 min

## Real readings

Scale a knob to millivolts, and guard every sum against overflow.

Lesson | Time | What students do

Scaling ADC readings Turn a 0 to 1023 knob reading into millivolts four ways: a 16-bit sum that wraps, a long divide, a float, and a multiply and shift, timed against each other. | 40 min

- Run it: turn the knob up
- The 16-bit trap
- Right, but slow
- Multiply and shift
- Sixteen fraction bits

Overflow guards What an int16_t does past 32767, and three guards: saturating adds, __builtin_add_overflow and checking before a multiply, on a knob-driven rocket speed. | 40 min

- Run it: 30000 + 10000
- Saturate instead
- Let the compiler check
- Full throttle
- A redline of your own

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED
- Potentiometer
- Resistor

### Check for understanding

Each student finishes "Overflow guards" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A redline of your own".

Chapter 3. About 1 h 25 min

## Tables and trig

Work it out once and look it up: gamma curves and a quarter-wave sine.

Lesson | Time | What students do

Lookup tables Gamma-correct an LED from a 33-entry table kept in flash with PROGMEM, time it against pow(), then interpolate between entries with integers only. | 40 min

- Run it: pow() against a table
- Flash, not SRAM
- Turn the knob: steps
- Interpolate
- One count short

Fast trig Sine and cosine from a 65-entry quarter-wave table in Q1.14, with binary angles that wrap on their own, timed against sin() and flown as a satellite orbit. | 45 min

- Run it: sin() against isin()
- Binary angles
- Four quarters from one
- How wrong is it?
- An orbit
- A higher orbit

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED
- Potentiometer
- Resistor

### Check for understanding

Each student finishes "Fast trig" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A higher orbit".

Chapter 4. About 45 min

## Project

A fixed-point filter on a noisy knob, measured and tuned.

Lesson | Time | What students do

Project: a fixed-point filter Smooth a noisy knob with an exponential moving average three ways, in float, in plain integers and in Q8, then measure the stall, the cost and the settle time, and tune it. | 45 min

- Run it: the integer stall
- What each one costs
- Step the knob
- Tune it
- Take the noise away
- Make it yours

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED
- Potentiometer
- Resistor

### Check for understanding

Each student finishes "Project: a fixed-point filter" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
