0

I am having a hard time understanding the >>> bitwise operator in java .

 int a = 60;
 int c = 0;
 c = a >>> 2;
 System.out.println("a >>> 2 = " + c );

Result is 15

But how does it become 15 ?

user2650277
  • 6,289
  • 17
  • 63
  • 132
  • 3
    how do you google Logical right shift if you don't know its name? – 1010 Jun 25 '15 at 17:42
  • https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html - quick explanation of bitwise and bitshift operators. – rodit Jun 25 '15 at 17:43
  • 1
    @1010: Guess what happens if you just Google using this question's title? – T.J. Crowder Jun 25 '15 at 17:44
  • Related: [Difference between >>> and >>](http://stackoverflow.com/questions/2811319/difference-between-and). – rgettman Jun 25 '15 at 17:46
  • @Crowder I get reference to other operators. But worse, the SO suggestions when you write the title must have shown some duplicates. – 1010 Jun 25 '15 at 17:54

1 Answers1

5

60 in binary is 111100. Right-shift two and you get 1111. That's 15

Ryan
  • 2,058
  • 1
  • 15
  • 29