Logical Xor '^'
Positron16 · Revision 1.1.3.5 · PDF page 85
Syntax
Assignment Variable = Variable ^ Variable
Overview
The Xor operator returns the bitwise Xor of two integer 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
Variables may be constants, variables or expressions. Assignment Variable can be any valid variable type.
Example
Device = 24FJ64GA002 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600 ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim MyByte1 as Byte = %00001111
Dim MyByte2 as Byte = %10101001
Dim MyResult as Byte
PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX) ' Make Pin RB14 U1TX
MyResult = MyByte1 ^ MyByte2
HrsoutLn Bin MyResult ' Display xor result (%10100110)
or
HrsoutLn Bin (%00001111 ^ %10101001) ' Display xor result (%10100110)
Bitwise operations are not permissible with floating point values or variables.
