在C语言中,&,丨,^的运算规则是什么
在C语言中,&,丨,^的运算规则是什么
日期:2021-12-28 02:41:28 人气:1
1、&:位与运算,遇0得0.即
0 & 0 = 0
0 & 1 = 1
1 & 0 = 0
1 & 1 = 1
2、|:位或运算,遇1得1,即
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1
3、^:异或运算,在或的基础上1异或1得0
0 ^ 0 = 0
1 ^ 0 = 1
0 ^ 1 = 1
1 ^ 1 = 0 /
0 & 0 = 0
0 & 1 = 1
1 & 0 = 0
1 & 1 = 1
2、|:位或运算,遇1得1,即
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1
3、^:异或运算,在或的基础上1异或1得0
0 ^ 0 = 0
1 ^ 0 = 1
0 ^ 1 = 1
1 ^ 1 = 0 /