Part 2: The beauty of bitwise AND (∧ or &)

Cédric Bellet

784

top tip. most programming languages use & for and and ^ for xor which makes this a bit harder to read than necessary

also, did you notice that there is an identity element in the case of integers mod 2^n , the number with all the bits set?

also, that it is associative? a & b & c is unambiguous i.e. the same as (a & b) & c and a & (b & c) — and so forms the mathematical structure called a semi-group (there is no inverse since & destroys information so its just shy of being a full group — like division) and so all of the theorems that can be applied to that structure apply to & over intergers mod 2^n (which is how integers are represented by computers)