xor
xor
xor is a logical “exclusive or” operator
syntax
details
the xor logical operator compares two expressions and returns the boolean value true if one and only one of the expressions is true (non-zero). See the table below for possible results.
expression 1 expression 2 result true true false true false true false true true false false false
Logical operators are not to be confused with Bitwise Operators.
example
In this example a comparison is performed on two integer variables using an if-statement.
' SharpBASIC xor programming example
' ----------------------------------
incl "lib/sys.sbi";
dim a, b: int;
main do
a = 1;
b = 0;
if a xor b do
print(true);
else do
print(false);
end
end
Output:
-1
xor.txt · Last modified: 2023/06/26 10:42 by admin