Learn C++ STL

Lesson 5 of 9 · bitset and Bit Tricks: Sixty-Four Booleans in One Word

Module 15 · bitset and Bit Tricks: Sixty-Four Booleans in One Word

Words, Padding, and a Sieve Performance Lab

ProReading

Maria asks why one shift can move so many answers. Kenji says the processor moves the whole bitset at once. Amara opens a two-word drawing. The useful explanation is smaller than Kenji's claim, and it also explains the boundary bugs.

Checking what this lesson needs for you…

What is inside Words, Padding, and a Sieve Performance Lab

  1. A word holds several answers
  2. Padding is outside the logical width
  3. A shift crosses word boundaries
  4. Count does not promise one CPU instruction
  5. Lab rules before the stopwatch
  6. A second lab isolates the transition shape
  7. Memory placement is another boundary