0

Why do we do unsigned right shift?. What is the purpose of the unsigned right shift operator ">>>" in Java?

public class Test {

  public static void main(String args[]) {
     int a = 60;    /* 60 = 0011 1100 */  

     c = a << 2;     /* 240 = 1111 0000 */
     System.out.println("a << 2 = " + c );

     c = a >> 2;     /* 215 = 1111 */
     System.out.println("a >> 2  = " + c );

     c = a >>> 2;     /* 215 = 0000 1111 */
     System.out.println("a >>> 2 = " + c );
  }
}

https://stackoverflow.com/a/16763943/2805694. I looked into the first answer and others too in the topic but not able to understand on why do we do it.

4

0 回答 0