Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Summary

OperationPurposeExample Use Case
ANDMasking/ClearingExtract specific bits
ORSettingTurn on flag bits
XORToggling/ComparingFlip bits, find differences
NOTInversionCreate complementary masks
BSLMultiplicationFast multiply by power of 2
BSRDivisionFast divide by power of 2

Bitwise operators are one of those tools that seem esoteric until the moment you need them, at which point they become indispensable. They represent a direct line to the machine’s native operations—a reminder that underneath all the high-level abstractions, computers are still just flipping bits according to Boolean logic, and sometimes it’s useful to speak their language directly.