The difference between right-shift operator >> and unsigned right-shift operator >>> in Java
In making a PCM audio encountered this character, but I see some of the Baidu's interpretation of the place can not make me very understand, so I sorted.
First, the difference between left and right shifts is well differentiated.
Shift left << : That is, the number corresponds to the total left of the binary code, left out of the partial discard, 0 on the right. For example: 253 of the binary code of11 1101, after the operation 253<<2 to get 1111 0100. It's simple .
Shift Right >> : the number corresponding to the binary code of the whole right shift, the left side with the original flag is added, the right part of the excess to discard.
Unsigned right shift >>> : Regardless of the positive or negative flag bit is 0 or 1, the number of binary code to move the whole right, the left part is always filled with 0, the right part is discarded.
Example comparison:
-5 in binary notation 1111 1011 , red for that number flag bit
-5>>2: 1111 1011-------------->1110 .
11 for the flag bit
-5>>>2: 1111 1011-------------->xx1110 .
00 for the supplement of 0
Java left shift <<&>> right shift &>> unsigned right shift