XOR (exclusive OR) results in 1 if bits are different (1 0 or 0 1) and 0 if bits are equal (0 0 or 1 1). So in our case if number is 00001010 and our mask is 00100000 (5th bit values are differ), result is 1 and 00101010. And if number is 00101010 and our mask is 00100000 (5th bit values are equal), result is 0 and 00001010.