Exactally! The >>> operator is called a
singed shift becuase it preserves the
value of the highest order bit. Heres a little
program that i whipped up.
Code:
/*
class created on 03/30/01
author brandon rohlfs
the purpose of this code is to show the process of
using the shift operators.
a left shift can be calculated by multiplying the number
being shifted by 2n, where n is the number of places being shifted
*/
import java.io.*;
class ShiftSamples{
public static void main(String[] args ){
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.println("Welcome to the shifter program");
System.out.println();
System.out.println("Enter the number you would like shift");
String numtoshift = buff.readLine();
System.out.println("and the amount of places you would like to shift");
String placestoshift = buff.readLine();
int shiftresult = 0;
shiftresult = Integer.parseInt(numtoshift) << Integer.parseInt(placestoshift);
System.out.println(numtoshift + " shifted " + placestoshift + " places " + " equals " + shiftresult);
}catch(IOException e){};