为什么我们做无符号右移? 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。我在主题中查看了第一个答案和其他答案,但无法理解我们为什么要这样做。