XOR                                                                        Operator

result = x XOR y

Description

XOR returns the logical, exclusive disjunction of two expressions. result is TRUE, if and only if one of the expressions x and y evaluate to TRUE, otherwise, result is FALSE.

XOR also does a bitwise comparison of two numeric expressions. Each bit in result is set to 1 if and only if one of the corresponding bits in x or y is 1, otherwise it is set to 0.

Example

REM XOR Example

'XOR performs exclusive disjunctions

DIM Test1, Test2, x, y

x = 2

y = 9

Test1 = x > 0 XOR y < 10

Test2 = x > 0 XOR y > 10

PRINT "Logical:"

PRINT "  x > 0 XOR y < 10 = " & CSTR(Test1)

PRINT "  x > 0 XOR y > 10 = " & CSTR(Test2)

PRINT "Bitwise:"

PRINT "  x XOR y = " & (x XOR y)

Output

Logical:

  x > 0 XOR y < 10 = False

  x > 0 XOR y > 10 = True

Bitwise:

  x XOR y = 11

Related Items

AND, EQV, IMP, NOT, OR