Lessons
Courses

Bitwise AND ( & ) [ English ]

Bitwise AND compares each bit of two integers. A bit is set to 1 in the result only if both corresponding bits are 1; otherwise, it becomes 0.

Examples

  1. 5 & 3

    • 5 = 0101
    • 3 = 0011
    • Result = 0001 = 1
  2. 12 & 10

    • 12 = 1100
    • 10 = 1010
    • Result = 1000 = 8
  3. 7 & 4

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