Bitwise AND

AND outputs 1 only where both inputs are 1 — the masking operator. x & 0b1111 keeps the low nibble; flags & FLAG tests a bit.

Category
Bit Manipulation
Time complexity
O(1)
Space complexity
O(1)

Pseudocode

for each bit position
  out = a AND b
used for masking bits off

Reference implementation

  10101100  (172)
& 11001010  (202)
  --------
  10001000  (136)
# mask: keep only chosen bits

Open the interactive Bitwise AND visualisation →