What is the difference between << (left shift) and >> (right shift) operators ?

Question :

What is the difference between << (left shift) and >> (right shift) operators ?

<< (left shift) Shift the bits of the number to the left by the number of bits specified. (Each number is represented in memory by bits or binary digits, i.e., 0 and 1)

For example, 2 << 2 gives 8.2 is represented by 10 in bits.

Left shifting by 2 bits gives 1000 which represents the decimal 8.

>> ( right shift) Shift the bits of the number to the right by the number of bits specified.
For example, 11 >> 1 gives 5.
11 is represented in bits by 1011, which when right shifted by 1 bit gives 101 which is the decimal 5.


Similar Questions


Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad