Why is x & 0
different from x & ~1
?
Shouldn't ~1
and 0
be the same since 0
is the complement of ~1
?
x = 21
print(f"x = {bin(x)}")
print(f"x & 0 = {bin(x & 0)}")
print(f"x & ~1 = {bin(x & ~1)}")
results in
x = 0b10101
x & 0 = 0b0
x & ~1 = 0b10100