Module M33 · 33 of 35 in teaching order · Intermediate
Bit Manipulation
Binary representation, two’s complement, masks and the standard bit tricks.
Lessons
Set, clear, toggle and test bits with masks, isolate the lowest set bit, count bits with Kernighan’s trick, and read the same bits as signed or unsigned.
Topics this module covers
The full module scope. Topics without a lesson above are not written yet.
- binary
- signed values
- two's complement
- AND/OR/XOR/NOT
- shifts
- masks
- set/clear/toggle
- population count
- patterns