[prev] 19 [next]

Bitwise OR

The | operator
  • takes two values (1,2,4,8 bytes), treats as sequence of bits
  • performs logical OR on each corresponding pair of bits
  • result contains same number of bits as inputs
Example:

  00100111            OR | 0  1
| 11100011           ----|-----
  --------             0 | 0  1
  11100111             1 | 1  1

Used for e.g. ensuring that a bit is set