 Chapter - 4 : Bitwise Operators

## #1 "&" Bitwise AND

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 `

## #2 "|" Bitwise OR

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 `

## #3 "~" Bitwise NOT

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 `

Note : Bitwise not of any operand x results in the output of -(x+1).

## #4 "^" Bitwise XOR

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`

## #5 "<<" Bitwise Left Shift

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 `

## #6 ">>" Bitwise Right Shift

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 `

## #7 ">>>" Bitwise Right Shift with Zero

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 `