Home / Guides / Understanding bitwise operations

Understanding bitwise operations

Bitwise operations work on the individual binary bits of an integer.

Basic logic operations

AND(&) is 1 only when both bits are 1, OR(|) is 1 if either bit is 1, and XOR(^) is 1 when the bits differ. NOT(~) flips every bit.

Shift operations

A left shift(<<) pushes bits left, multiplying by a power of two, while a right shift(>>) divides. For example, 1 << 4 = 16.

This tool's bit grid lets you see the result of shifts and masks visually.

Where it's used

It's common in low-level work: packing many flags into one integer, handling permission masks, or splitting color channels.