1027luke / thisisjava

thisisjava
0 stars 0 forks source link

[Homework] Operation, Operand, Expression #5

Closed maxpaper86 closed 5 years ago

maxpaper86 commented 5 years ago

Operation

difference between bit and logical expression

Practice

Consider we are handling one byte data only.

  1. Arithmetic expression

  2. (5*3)%7

  3. Bit expression

  4. 5 << 2

  5. 7 << 4

  6. 112 >> 3

  7. 63 >> 5

  8. 17 | 5

  9. 1 | 50

  10. 12 & 11

  11. 121 & 12

  12. 42 ^ 11 10 7 ^ 37

  13. ~43

  14. ~110

  15. Logical expression

  16. 999 && 0

  17. 1 && 1

  18. 0 && 0

  19. 1 && 999

  20. 999 || 0

  21. 1 || 1

  22. 0 || 0

  23. 1 || 999

  24. 20 < 20

  25. 20 <= 20

  26. 40 != 41

  27. 11 == 11

  28. Mixed expression

  29. print x value for every line x = 0; x++; x += 5; x <<= 2; x |= 3; x = ~x + 1; x ^= 11; x = x && 1

1027luke commented 5 years ago
  1. Arithmetic expression

  2. 1

  3. Bit expression

  4. 20

  5. 112

  6. 14

  7. 3

  8. 1

  9. 51

  10. 1

  11. 1

  12. 0

  13. 34

  14. 0

  15. 111

  16. 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
  1. Mixed expression
    0
    1
    6
    24
    27
    -27
    -18
    True