Caché MultiValue Basic Reference
BITXOR


Returns the bitwise XOR for two bit strings.
Synopsis
BITXOR(bitstring1,bitstring2)
Arguments
Description
The
BITXOR function compares two bit strings bitbybit, and returns a bitstring that is the logical exclusive or (XOR) bitwise comparison of the two strings. Both
bitstring values are specified as positive integers. The returned value is also expressed as a positive integer.
The following is the truth table for
BITXOR:
A
bitstring can be expressed as either a number or as a string. A number are converted to canonical form, with leading plus signs and leading and trailing zeros omitted. If either argument evaluates to the null string or a nonnumeric string it is assumed to have a value of 0. A string is parsed as a number until a nonnumeric character is encountered. Thus “7dwarves” is parsed as 7.
Examples
The following example specifies a
bitstring1 of 14 (binary 1110), and a
bitstring2 of 9 (binary 1001). Bitwise XOR comparison results in the binary string 0111, the integer value of which is 7:
PRINT BITXOR(14,9); ! Returns 7
The following example specifies a
bitstring1 of 14 (binary 1110), and a
bitstring2 of 6 (binary 110). Bitwise XOR comparison results in the binary string 1000, the integer value of which is 8:
PRINT BITXOR(14,6); ! Returns 8
The following example specifies a
bitstring1 of 65 (binary 1000001), and a
bitstring2 of 62 (binary 111110). Bitwise XOR comparison results in the binary string 1111111, the integer value of which is 127:
PRINT BITXOR(65,62); ! Returns 127
The following example specifies two bitstrings with the same integer value. Bitwise XOR comparison of a number with itself always results in 0:
PRINT BITXOR(64,64); ! Returns 0
See Also