See the Code Demo:
Package day02;/** * >> and >>> difference? */public class MyTest {public static void main (string[] args) {/* * 5 * * 00000000 00000000 00000000 00000101 */int A = 5;int A1 = A>>1;int A2 = a>>>1; System.out.println (a1+ "--" +a2); 2--2/* *-5 * * 10000000 00000000 00000000 00000101 --Original code * 11111111 11111111 11111111 11111010 --Anti-code * 111111 11111111 11111111 11111011 --Complement * * 11111111 11111111 11111111 11111101 --(-3) * 01111111 11111111 1111111 1 11111101 -(2147483645) */int b = -5;int B1 = b>>1;int B2 = b>>>1; System.out.println (b1+ "--" +b2); -3--2147483645/* * Summary: * 1.>> need to consider the symbol bit * 2.>>> do not consider the sign bit, the missing bit number 0 * * * * }}
It is wrong to also look at the correct!!!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The difference between >> and >>> in Java