||The article was great but I could not understand if A = 1010, how is ~A = 11110101?
Quoting the paragraph from https://www.topcoder.com/community/data-science/data-science-tutorials/a-bit-of-fun-fun-with-bits/ below:
Thus, if A is 1010 and B is 1100, then
A & B = 1000
A | B = 1110
A ^ B = 0110
~A = 11110101 (the number of 1's depends on the type of A).