Lessons
Courses

Bitwise OR ( | ) [ English ]

Bitwise OR ( | )

Bitwise OR compares each bit of two integers. A bit in the result is 1 if at least one of the corresponding bits is 1; it is 0 only when both bits are 0.

Examples

  1. 5 | 3

    • 5 = 0101
    • 3 = 0011
    • Result = 0111 = 7
  2. 12 | 10

    • 12 = 1100
    • 10 = 1010
    • Result = 1110 = 14
  3. 7 | 4

    • 7 = 0111
    • 4 = 0100
    • Result = 0111 = 7