& | ^ ~ << >>及练习代码

package operator;

public class Dome06 {
public static void main(String[] args) {
/*
A = 0011 1100
B = 0000 1101

A&B = 0000 1100 00=0 11=1 01 or 10 = 0 &与:相同则为本身值,不同则为0
A|B = 0011 1101 00=0 11=1 01 or 10 = 1 |或:相同则为本身值,不同则为1
A^B = 0011 0001 ^亦或 相同则为0,否则为1
~B = 1111 0010 ~取反 取相反值

面试题
2*8 = 2*2*2*2 怎么运算最快?
<<左移 *2
>>右移 /2
二进制模型
0000 0000 0
0000 0001 1
0000 0010 2
0000 0011 3
0000 0100 4
0000 1000 8
0001 0000 16


*/

System.out.println(2<<3);

}
}
posted @ 2021-02-24 17:49  恶的反思  阅读(74)  评论(0)    收藏  举报