If the first operand is an int or uint (32-bit quantity), the shift count is given by the low-order five bits of the second operand (second operand & 0x1f).

If the first operand is a long or ulong (64-bit quantity), the shift count is given by the low-order six bits of the second operand (second operand & 0x3f).

If the first operand is an int or long, the right-shift is an arithmetic shift (high-order empty bits are set to the sign bit). If the first operand is of type uint or ulong, the right-shift is a logical shift (high-order bits are zero-filled).

User-defined types can overload the >> operator; the type of the first operand must be the user-defined type, and the type of the second operand must be int. For more information, see operator. When a binary operator is overloaded, the corresponding assignment operator, if any, is also implicitly overloaded.

 

// cs_operator_right_shift.cs
using System;
class MainClass
{
    static void Main() 
    {
        int i = -1000;
        Console.WriteLine(i >> 3);
    }
}

 

 import java.io.*;
// javac operators_shift.java
public class operators_shift
{
public static void main(String args[])throws IOException
{
int unary = 0;
int preIncrement;
int preDecrement;
int postIncrement;
int postdecrement;
int positive;
int negative;
byte bitNot;
boolean logNot;
int s =1000 ;
///shift right
System.out.println("---shift right >> operator---");
System.out.print(" s>>1 is : " );
System.out.println( s>>1);
System.out.print(" s>>2 : " );
System.out.println( s>>2);
System.out.print(" s>>3 : " );
System.out.println( s>>3);
/////shift left
System.out.println("---shift left >> operator---");
System.out.print(" s <<1 is : " );
System.out.println( s<<1);
System.out.print(" s<<2 is : " );
System.out.println( s<<2);
System.out.print(" s<<3 is : " );
System.out.println( s<<3);

}
}