Bitwise Operators
Operator
Description
Example
Evaluation
Result
&
Bitwise AND between the left and right Operands. (Consider Both Operand Value in Binary)
12 & 5
00001100
00000101
00000100
4
|
Bitwise OR between the left and right Operands. (Consider Both Operand Value in Binary)
12 | 5
00001100
00000101
00001101
13
^
Bitwise EXCLUSIVE OR between the left and right Operands. (Consider Both Operand Value in Binary)
12 ^ 5
00001100
00000101
00001001
9
~
Bitwise COMPLEMENT of the Operand. (Consider Operand Value in Binary)
~12
00001100
11110011
01110011 00001100 00000001 00001101
13
<<
Bitwise LEFT SHIFT of the left operand, Number of bit(s) to be shifted to be defined by the right Operand. (Consider Left Operand Value in Binary)
12<<2
00001100
0000110000
48
>>
Bitwise RIGHT SHIFT of the left operand, Number of bit(s) to be shifted to be defined by the right Operand. (Consider Left Operand Value in Binary)
12>>2
00001100
00000011
3
Last updated