Step Into C · Lesson 14 · Modeling Data
Bits & Bytes
Binary and hex, bitwise operators, masks, flags, shifts and alignment.
- ~35 minreading and coding
- 4missions
- membersaccess
- Clanguage
Part of Step Into C. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.
Every integer is a row of bits. Hex is the programmer's shorthand for it, because one hex digit is exactly 4 bits and two hex digits are one byte:
In this lesson
- Thinking in binary
- The bitwise operators
- Flags: many booleans in one integer
- Extracting bytes with shifts and masks
- Powers of two and alignment
Missions
- Flags
- Take it apart
- Count the ones
- Align up