Abstract

The bitwise or expression is used to compute the bit-by-bit Boolean XOR (exclusive OR) of two integer values. 

Usage

Syntax

Syntax Diagrams

Bitwise XOR Expression Syntax Diagram

BNF

bitwise-xor-expression
::= <bitwise-and-expression>
::= <bitwise-xor-additive-expression> <bitwise-xor-operator> <bitwise-and-expression>
bitwise-xor-operator
::= '^'

EBNF

bitwise-xor-expression
::= <bitwise-and-expression> ( <bitwise-xor-operator> <bitwise-and-expression> ) *
bitwise-xor-operator
::= '^'

Contextual Constraints

bitwise-xor-operator
The operands of the XOR operator should be of int type. 
The operands of the XOR operator will be coerced to int type if possible. 

Semantics

bitwise-xor-expression
For each bit position, the result is 0 iff the operands are equal in that bit position.
For each bit position, the result is 1 iff the operands are unequal in that bit position.
The value of each bit is the boolean XOR of that bit of the operands:
Boolean XOR
Operands Value
000
011
101
110
The bitwise XOR operator uses full evaluation.  It does not short circuit. 

Reference Links

Bitwise Exclusive Or Operator <exclusive-or-operator>
And Expression <and-expression>

Other Languages

C Now
C Bitwise XOR Expression
C++ Now C++ Bitwise XOR Expression
Java Now Java Bitwise XOR Expression
PHP Now PHP Bitwise XOR Expression