0PricingLogin
Zig Academy · Lesson

Bitwise Operators

AND, OR, XOR, NOT, and shifts.

Down to the Bits

Every integer is really a row of bits. Bitwise operators let you work on those individual ones and zeros directly, with no rounding or math in between.

Bitwise AND

The & operator keeps a bit only where both inputs have a 1. It is the classic tool for masking off the bits you do not want.

const masked = value & 0x0F;

All lessons in this course

  1. Arithmetic and Comparison Operators
  2. Overflow: + vs +% vs +|
  3. Bitwise Operators
  4. Boolean Logic and Short-Circuiting
← Back to Zig Academy