What are bitwise shift operators?
The bitwise operators are used for shifting the bits of the first operand left or right. The number of shifts is specified by the second operator.
Expression <> number of shifts
number<>2; /* number is an operand â€“ shifts 2 bits towards right*/
The variable number must be an integer value.
For leftward shifts, the right bits those are vacated are set to 0. For rightward shifts, the left bits those are vacated are filled with 0â€™s based on the type of the first operand after conversion.
If the value of â€˜numberâ€™ is 5, the first statement in the above example results 40 and stored in the variable â€˜numberâ€™.
If the value of â€˜numberâ€™ is 5, the second statement in the above example results 0 (zero) and stored in the variable â€˜numberâ€™.