//program to demonstrate shift operations
public class shiftoperation
{
public static void main(String args[])
{
int a=-67890346;
int o1=a<<3; // left shift
int o2=a>>3; // right shift
int o3=a>>>3; //unsigned right shift
System.out.println("The original value is"+ShiftBit(a));
System.out.println("the left shift value is"+ShiftBit(o1));
System.out.println("The right shift value is"+ShiftBit(o2));
System.out.println("The unsigned shift value is"+ShiftBit(o3));
}
private static String ShiftBit(int x)
{
StringBuffer buf = new StringBuffer();
for (int i=1; i<=32; i++)
buf.append(x>>>(32-i) & 0x00000001);
return buf.toString();
}
}