%^ Operator

Purpose

Performs a bitwise exclusive OR operation between two integer values.

Syntax

i %^ j

Description

The bitwise-exclusive-OR operator %^ compares each bit of its first operand to the corresponding bit of its second operand. If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

Bit1 Bit2 Result
0 0 0
1 0 1
0 1 1
1 1 0

%^ is equivalent to the ^ operator. For more information see %&.

Example

Print Bin$(3, 4)        //  prints  0011

Print Bin$(3 %^ 10, 4//  prints  1001

Remarks

x Xor y is synonymous with x %^ y and can be used instead.

See Also

Xor, And, %&, Or(),%|, Imp(), Eqv(), Operator Hierarchy

{Created by Sjouke Hamstra; Last updated: 17/09/2014 by James Gaite}