Xor can be used as a command, an operator, and as a function, Xor8 just as operator and function. They both perform an exclusive bit-wise Or on two bit patterns.
Xor ivar, j( command)
int = i Xor j( operator)
int = Xor(i, j [,m,…])( function)
int64 = i Xor8 j( operator)
int64 = Xor8(i, j)( function)
int:32-bit integer variable
int64:64-bit integer variable
i,j:integer expression
i Xor j sets only the bits which are set in one - and only one - of the operands.
Bit 1 | Bit 2 | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
The arguments are converted to Long (or Large for Xor8) before the operation is performed (using CLong).
Debug.Show
Trace Bin$(3, 4) // Prints 0011
Trace Bin$(10, 4) // Prints 1010
Trace Bin$(Xor(3, 10), 4) // Prints 1001
Local a% = 3
Xor a%, 4
Trace Bin$(a%, 4) // Prints 0111
Trace Bin$(Xor8(3, 10), 4) // Prints 1001
And ,Or, Xor, Imp, Eqv, %&, |, ~, Operator Hierarchy
{Created by Sjouke Hamstra; Last updated: 25/10/2014 by James Gaite}