It performs the AND operation on the binary equivalent of the given operands and return 1
where
both the operands are 1
.
Try it by checking the following numbers in the terminal 5 & 6
It performs the OR operation on the binary equivalent of the given operands and return 1
if
any of the operand is 1
.
Try it by checking the following numbers in the terminal 5 | 7
It inverts the bits of the operands i.e. returns 1
where it was 0
and 0
where it was 1
Try it by checking the following numbers in the terminal ~5
It perfroms the XOR operations on the bits that is the operand will return 1
when one
of the two operand is 1
and returns 0
if both the operands are either 1
or 0
Try it by checking the following numbers in the terminal 2 ^ 5
This operator is used to shift the first operand to the left and replacing the digits by 0 to the amount specified
by the value of second operand.
For example : 5 << 2 i.e.
101 << 2
Output :
10100
Try it by checking the following numbers in the terminal 7 << 2
This operator is used to shift the first operand to the right and replacing the digits by 0 to the amount specified
by the value of second operand.
For example : 5 >> 2 i.e.
00101 >> 2
Output :
00001
Try it by checking the following numbers in the terminal 7 >> 2
This operator is used to shift the first operand to the right and replacing the digits by 0 to the amount specified
by the value of second operand.However it will always return a non-negative number because the sign is not preserved.
For example : 5 >>> 2 i.e.
00101 >>> 2
Output :
00001
Try it by checking the following numbers in the terminal 7 >>> 2