All paths

Fixed-point and integer math

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.

Arduino Uno R3Free7 lessons5 h4 chapters2,667 XPCoding · Advanced+250 XP

0 of 7 done

What you will build

3 projects, built step by step

7 lessons in 4 chapters, about 5 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

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.

Open it in the simulator
Chapter 2 project

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.

Open it in the simulator
Chapter 3 project

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.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

Floats and Q numbers

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

  1. Open250 XP

    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.

    0 of 5 steps

  2. ProjectLocked576 XP

    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.

    0 of 6 steps

5 questions, graded as you go.
Chapter 2

Real readings

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

  1. Locked250 XP

    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.

    0 of 5 steps

  2. ProjectLocked500 XP

    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.

    0 of 5 steps

4 questions, graded as you go.
Chapter 3

Tables and trig

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

  1. Locked250 XP

    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.

    0 of 5 steps

  2. ProjectLocked576 XP

    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.

    0 of 6 steps

5 questions, graded as you go.
Chapter 4

Project

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

  1. Locked265 XP

    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.

    0 of 6 steps

3 questions, graded as you go.
Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

Floats and Q numbers

  1. Why floats costThe 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.
  2. Q formatsFractions 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.
Chapter 2

Real readings

  1. Scaling ADC readingsTurn 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.
  2. Overflow guardsWhat 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.
Chapter 3

Tables and trig

  1. Lookup tablesGamma-correct an LED from a 33-entry table kept in flash with PROGMEM, time it against pow(), then interpolate between entries with integers only.
  2. Fast trigSine 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.
Chapter 4

Project

  1. Project: a fixed-point filterSmooth 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.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Fixed-point and integer math

Is Fixed-point and integer math free?

Yes. All 7 lessons of Fixed-point and integer math are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Fixed-point and integer math take?

About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Q formats, Overflow guards and Fast trig.

Where do I start?

With "Why floats cost", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.