Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • C Bitwise Right Shift : (>>) Operator

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 54
    Comment on it

    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.

     

    1. It is denoted by >>
    2. Bit Pattern of the data can be shifted by specified number to the right side
    3. When Data is Shifted Right , remaining are filled with zeros.
    4. Right shift Operator is Binary operator  [Bi – two]
    5. 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

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: