; Xor Example ; ----------- ; Xor is true when its two sides DIFFER. Bitwise, a bit comes out set ; when exactly one of the inputs has it. a=%1100 b=%1010 Print "a = "+Bin$(a)+" ("+a+")" Print "b = "+Bin$(b)+" ("+b+")" Print "a Xor b = "+Bin$(a Xor b)+" ("+(a Xor b)+")" Print "" ; Xor's party trick: applying the same mask twice restores the ; original - the classic lightweight scramble message=12345 mask=54321 scrambled=message Xor mask Print "message = "+message Print "message Xor mask = "+scrambled+" (scrambled)" Print "scrambled Xor mask = "+(scrambled Xor mask)+" (the original is back)" Print "" ; Xor 1 flips a true/false flag each time it runs - a one-line toggle sound_on=True sound_on=sound_on Xor 1 Print "Toggle once : sound_on = "+sound_on sound_on=sound_on Xor 1 Print "Toggle again: sound_on = "+sound_on Print "" Print "Press any key to close the example" WaitKey End