*BitXOr Operator

Estimated reading time: 3 minutes

Used to perform a logical exclusive OR on two Boolean expressions, or a bitwise exclusive OR on two integer values.

 *result*  = ** *expression1* **  *BitXOr ** *expression2* ** 

Parameters

result

Required. Any Boolean or numeric expression. For Boolean comparison the result is the logical conjunction of two expressions. For bitwise operations the result is a numeric value resulting from the bitwise conjunction of two numeric expressions.

expression1

Required. Any Boolean or numeric expression. If not an integer, it is converted to an integer before the bitwise exclusive OR operation is performed.

expression2

Required. Any Boolean or numeric expression. If not an integer, it is converted to an integer before the bitwise exclusive OR operation is performed.

Remarks

For Boolean comparison, if both expression1 and expression2 evaluate to True, result is False. If expression1 evaluates to True and expression2 evaluates to False, result is True. If expression1 evaluates to False, and expression2 evaluates to True, the result is True. The following table illustrates how result is determined:

If *expression1* is And *expression2* is Then *result* is
True True False
True False True
False True True
False False False

For bitwise operations, the bitXOr operator performs a bitwise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in ** *result ** according to the following table:

If bit in *expression1* is And bit in *expression2* is Then *result* is
0 0 0
0 1 1
1 0 1
1 1 0

Note Since the logical/bitwise operators have a lower precedence than other arithmetic and relational operators, any bitwise operations should be enclosed in parentheses to ensure accurate execution.

If the operands consist of one Boolean expression and one numeric expression, the result Boolean expression will be converted to a numeric value (-1 For True, and 0 For False) and the bitwise operation will result.

Example

dclconst   Hex24  Value( H"24" )
dclfld     Byte1   Type( *byte ) INZ( H"46")
dclfld     Byte2   Type( *byte )
dclfld     Int1      Type( *integer2 ) INZ( H"46" )
dclfld     Int2      Type( *integer2 )
dclfld     Bool1    Type( *Boolean ) 	INZ( *true )			
dclfld     Bool2    Type( *Boolean )
dclfld     Str2      Type( *string )

Byte2 = Byte1 *BitXor Hex24         // Byte2 = H"04"
Int2  = Int1 *BitXor Hex24          // Int2 = 4 or H"0004"
Bool2 = Int2 *BitXor H"11"          // Bool2 = False
Str2  = Int1 *BitXor Hex24          // Str2 = "4"
Int2  = Bool1 *BitXor H"0C00"       // Int2 = 4 or H'0004"	

See Also

Operators

Operators and Their Precedence