Logical Xor '^'
Positron8 · Revision 4.0.6.5 · PDF page 89
Syntax
Assignment Variable = Variable ^ Variable
Overview
The Xor operator returns the bitwise Xor of two values. Each bit of the values is subject to the following logic: -
0 xor 0 = 0 0 xor 1 = 1 1 xor 0 = 1 1 xor 1 = 0
The result returned by ^ will contain 1s in any bit positions in which one or the other (but not both) input values contain 1s.
Operands
Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.
Example 1
Device = 18F26K40 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600 ' Set the Baud rate for HRsoutLn
Dim bMyVar1 as Byte
Dim bMyVar2 as Byte
Dim bMyResult as Byte
bMyVar1 = 0b00001111
bMyVar2 = 0b10101001
bMyResult = bMyVar1 ^ bMyVar2
HRsoutLn Bin8 bMyResult ' Display the XOR binary result: 10100110
Example 2
Device = 18F26K40 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600 ' Set the Baud rate for HRsoutLn
HRsoutLn Bin8 (ob00001111 ^ 0b10101001) ' Display the XOR binary result 10100110
Note.
Bitwise operations are not permissible with floating point constants or variables.
