What is the '' operator used for in Java?

8

I have a problem with the use of the character '> >' I would like to know what function actually fulfills what it does considering something like:

System.out.println(5>>1); the result is 2 but why ?, I understand that it is also called operator Bits but really compares the bits of these numbers and determines that?

    
asked by theboshy 09.08.2017 в 15:13
source

1 answer

14

To find out why, you have to pass number 5 to binary: 00000101

The operator >> shifts X bits to the right depending on the number after the operator, in your case 1 bit , therefore 00000101 -> 00000010 which is 2

    
answered by 09.08.2017 / 15:19
source