Home / Learn Embedded C / Fixed-Point Math on MCUs Without an FPU

Fixed-Point Math on MCUs Without an FPU

Representing fractional values using scaled integers, on chips lacking hardware floating-point support.

Quick summaryRepresenting fractional values using scaled integers, on chips lacking hardware floating-point support.

How to think about this

What it is

Fixed-point math represents a fractional value as a scaled integer (like storing "1.5" as the integer 1500 with an implied scale of 1000, or using specific bit positions for the fractional part), letting chips without a hardware floating-point unit (FPU) still do fractional arithmetic efficiently using only integer operations.

Why it matters

Many simpler/cheaper microcontrollers (including many AVR chips and some Cortex-M0 variants) lack a hardware FPU — floating-point operations there are emulated in software, which is often far slower than native integer math; fixed-point is the standard technique to get fractional-value behavior without that cost.

Mechanically speaking

Choosing the right scale factor (how many bits/decimal digits of fractional precision) is a genuine design decision: more fractional precision costs range (since the same number of bits must now represent both the integer and fractional parts), and arithmetic must consistently account for the chosen scale.

Shows up in

  • FPU-less chip arithmetic
  • Sensor value scaling
  • Fast, predictable embedded math

Try it

Simple fixed-point arithmetic with a scale of 100 (2 decimal digits)C: edit and run

Note that multiplication needed an extra division by the scale factor to keep the result at the correct fixed-point scale — addition did not.

Careful:Fixed-point arithmetic requires carefully tracking the chosen scale factor through every calculation — multiplying two fixed-point values, for instance, requires dividing the raw integer product back down by the scale factor to keep the result at the correct scale.

Try it: dividing two fixed-point values

Fixed-point division, which must multiply by scale before dividingC: edit and run

Division needs the opposite correction from multiplication: the numerator is scaled up by the scale factor first, or the result would lose its fractional precision entirely.

Check yourself

1. Why is fixed-point math commonly used on microcontrollers lacking a hardware floating-point unit (FPU)?