Bit-Level Logic: Bitwise Operators and Masks in Python
·4130 words·20 mins
In Python, 5 and 6 returns 6, and 5 & 6 returns 4. We explain the difference and the bitwise operators AND, OR, XOR, NOT and the shifts, used in masks that check, set, clear and toggle bits. In the end, we see where the 755 in chmod comes from.