xor
Purpose
Bitwise exclusive or operator ^
Description
Sets bits in the result where equivalent bits are different in the number either side of the operator
Syntax
result = number1 ^ number2
Arguments
number1 first binary number
number2 second binary number
result resulting number with the bits set that are different between number1 and number2
Example
loop
textsize( 50 )
byte1 = 123
byte2 = 234
printAt( 0, 0, "byte1 = ", bin2str( byte1 ) )
printAt( 0, 1, "byte2 = ", bin2str( byte2 ) )
printAt( 0, 2, "byte1 ^ byte2 = ", bin2str( byte1 ^ byte2 ) )
update()
repeat
function bin2str( byte )
result = ""
for i = 0 to 8 loop
bit = byte & 1
if bit then
result = "1" + result
else
result = "0" + result
endIf
byte = byte >> 1
repeat
return result
Associated Commands