Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Part 1
A bitwise operator sees 12 and 10 as rows of bits. A bit is just a single 0 or 1. In binary, 12 is 1100, and 10 is 1010, four bits each.
Four columns, four separate pairs
Line them up and you get four pairs. The 8s column holds 1 and 1, the 4s hold 1 and 0, the 2s hold 0 and 1, the 1s hold 0 and 0. Each pair stands alone, with no carrying, unlike addition.
Bitwise operators pair matching bits, one column at a time.
Bitwise operators pair matching bits, one column at a time. The operator only decides what each pair becomes.
