BitXor
The BitXor function returns the bit-wise XOR of two numbers. The name XOR means "Exclusive OR" and refers to the case where 1 but not both numbers have a given bit "on". Use the bit-wise XOR to combine bits from separate numbers when each bit is present in one number but not the other.
nResult = BitXor( n1, n2 ) |
nResult is the bit-wise XOR of n1 and n2.
n1 and n2 are two numbers (integers).
The bit-wise XOR of two numbers saves all bits found exclusively in both numbers. Exclusive means that the bit was "on" in one number but not in both numbers. For example, consider the numbers 7 and 18. In binary notation these are expressed as 111 and 10010. The bit-wise XOR of 7 and 18 selects only the bits present in one but not both numbers, which gives 10101, or 21 decimal.
The following script performs the XOR of two numbers. Note that the result is printed using %u because it is considered an unsigned (i.e., 0 or positive) integer.
|
-- pick two numbers |
|
-- prints the result 21 |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics,
Inc. All Rights Reserved.