1,<< :左移运算符,
System.out.println(1<<1);//2
System.out.println(1<<2);//2*2
System.out.println(1<<3);//2*2*2
2,>>: 右移运算符
System.out.println(16>>1);//16/2
System.out.println(16>>2);// 16/2/2
System.out.println(16>>3);// 16/2/2/2
3,>>>: 无符号右移运算符
System.out.println(0x7ffffff); //134217727
System.out.println(0x7ffffff>>>24); //右移24位获取高8位 ----7
System.out.println(0x7ffffff>>>16);//134217727 / 2^16
System.out.println(0x7ffffff>>>8);// 134217727/ 2^8
System.out.println(0x7ffffff>>>0);// 34217727/ 2^0
4,<<<:无符号左移运算符
System.out.println(1<<<1);//2
System.out.println(1<<<2);//2*2
System.out.println(1<<<3);//2*2*2
网友评论