In C programming while working with the numbers you have multiple operators for it to perform manipulation over it.
Right shifting means we will shift the digit to the right side by the specified number of places.
It is denoted by >>
Bit Pattern of the data can be shifted by specified number to the right side
When Data is Shifted Right , remaining are filled with zeros.
Right shift Operator is Binary operator [Bi – two]
Binary means , Operator that require two arguments
Original Number A
0000 0000 0011 1100
Right Shift by 2
0000 0000 0000 1111
Leading 2 Blanks
Replaced by 0 ,Shown in RED
Direction of Movement of Data
Right ========>>>>>>
#include<stdio.h>
int main()
{
int a = 60;
printf("\nNumber is Shifted By 1 Bit : %d",a >> 1);
printf("\nNumber is Shifted By 2 Bits : %d",a >> 2);
printf("\nNumber is Shifted By 3 Bits : %d",a >> 3);
return(0);
}
Output
Number is Shifted By 1 Bit : 30
Number is Shifted By 2 Bits : 15
Number is Shifted By 3 Bits : 7
0 Comment(s)