Call Us : +91-8376986802 (Viber, WhatsApp)

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

Ex:

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’.

Leave a Reply