http://www.perlmonks.org?node_id=99482


in reply to Bitwise Operators - &^

but when 155 and 105 are XORed, that produces 240, not 242.

Says who? The exclusive or of two bit patterns contains a one for each mismatch pair of bits and a zero for each matched pair. Thus for 155 and 105:

# 1001 1011 - 155 # 0110 1001 - 105 # 1111 0010 - 242
The fun thing about XOR is that if you XOR the result with one of the input values, you get the other input value back:
# 1001 1011 - 155 # 1111 0010 - 242 # 0110 1001 - 105
Thus various encryption schemes (and some fun graphics programming on early PCs :)