Embedded systems and IoT

Stage 1 · Lesson 2 of 7

Fixed-width integer types

C for embedded

The size of int in C depends on the compiler and chip: 16 bits on the classic Arduino Uno, 32 bits on an or . Hardware does not care about your compiler, so embedded code uses the types in , such as uint8_t (an unsigned 8-bit value from 0 to 255), int16_t and uint32_t.

Use unsigned types for , bit patterns and counters, and signed types for values that can go negative, like temperature. Learn what overflow means: a uint8_t at 255 plus one becomes 0. Learn integer promotion too, where small types are widened to int before arithmetic, which surprises people in comparisons and shifts.

Common trapmixing signed and unsigned values in one comparison, so -1 is treated as a huge positive number and a check that looks right quietly fails.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Keep handy

Also worth your time

Mark this stage as not done?