Source: http://quigley.scs.ryerson.ca/~mth110/Handouts/bitwise.pdf