Skip to content

XOR

Binary Exclusive OR

This string function returns the logical exclusive OR, bit-by-bit, of two string expressions of equal length.

XOR (string-value1, string-value2 [,ERR=line-ref|,ERC=error-code])
string-value1,2
are any strings of equal length.
line-ref
specifies the program line number or label to branch to if an error is produced by this function.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

If string-value1 and string-value2 do not contain the same number of characters, an ERR=17 results.

This option is generally available starting with release level 8.1.

XOR ("A","B")

returns $03$ (0000 0011 in binary), which represents the result of the exclusive logical OR of A (0100 0001) and B (0100 0010).

PRINT DEC (XOR("A","B"))

returns the number 3, which is the decimal representation of the binary 0000 0011.

LET X$ = XOR (X$,Y$)

If X$ = “B” and Y$ = “A” returns the same result as the first example and assigns it to the X$.

XOR ("C", $01$)

returns the character B (0100 0010), which is the result of the exclusive OR of C (0100 0011) and $01$ (0000 0001).

AND, IOR, and NOT functions

From the Thoroughbred Basic Language Reference, Volume III: R–Z, version 8.9.1. Open this page in the PDF