Bitwise OR

OR outputs 1 where either input is 1 — the setting operator. flags | FLAG turns a bit on without touching the others.

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

Pseudocode

for each bit position
  out = a OR b
used for setting bits on

Reference implementation

  10101100  (172)
| 11001010  (202)
  --------
  11101110  (238)
# set: turn chosen bits on

Open the interactive Bitwise OR visualisation →