RETURNS THE BINARY LOGICAL "EXCLUSIVE OR" BETWEEN THE VALUES V1 AND V2
ACTION
The function BIN_XOR(V1,V2) returns the value of the binary logical "EXCLUSIVE OR" between V1 and V2.
V1 and V2 are data or variables which can be real or integer.
If a value is real, it is rounded to the nearest integer before the logical operation.
The logical operation is made bit-by-bit:
1 EXCLUSIVE OR 1 = 0
1 EXCLUSIVE OR 0 = 1
0 EXCLUSIVE OR 1 = 1
0 EXCLUSIVE OR 0 = 0
The operator "exclusive or" is in fact the operator "different": the result is 1 when the bits are different.
Applications:
to reverse bits
If the variable V1 has its value between 0 and 255, after V1=BIN_XOR(V1,255), all the bits of V1 are reversed: 1 becomes 0, and 0 becomes 1.
SYNTAX:
Result=BIN_XOR(V1,V2)
USE ERROR EXAMPLE
print bin_xor(3,7)
print "Result = 4"
BIN_XOR()
BIN_XOR(V1,V2)
SEE ALSO
BIN_AND()
BIN_OR()