bit shifting 01111110 we want to flip the xth (5th) bit so 0111_1_110 << 5 - 1 _1_1100000 inverse _0_0011111 _0_0011111 >>> 7 0000000_0_ 0000_0_000 << 8 - 5 store as A 01111110_ << 5 _110_00000 _110_00000 >>> 5 00000_110_ store as B _0111_1110 >>> 5 - 1 0000_0111_ 0000_0111_ << 5 - 1 _0111_0000 + A + B = 0111_0_110 We can also set a bit to 1 or 0 this way 0000000_1_ << 8 - 5 and store that as A instead.