Closed maxpaper86 closed 5 years ago
Arithmetic expression
1
Bit expression
20
112
14
3
1
51
1
1
0
34
0
111
Logical expression
1. False
2. True
3. False
4. True
5. True
6. True
7. False
8. True
9. False
10. True
11. True
12. True
0
1
6
24
27
-27
-18
True
Operation
difference between bit and logical expression
Practice
Consider we are handling one byte data only.
Arithmetic expression
(5*3)%7
Bit expression
5 << 2
7 << 4
112 >> 3
63 >> 5
17 | 5
1 | 50
12 & 11
121 & 12
42 ^ 11 10 7 ^ 37
~43
~110
Logical expression
999 && 0
1 && 1
0 && 0
1 && 999
999 || 0
1 || 1
0 || 0
1 || 999
20 < 20
20 <= 20
40 != 41
11 == 11
Mixed expression
print x value for every line x = 0; x++; x += 5; x <<= 2; x |= 3; x = ~x + 1; x ^= 11; x = x && 1