Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. ### AND (&)
  2. 100
  3. 101
  4. ---
  5. 100
  6. ### OR (|)
  7. 100
  8. 101
  9. ---
  10. 101
  11. ### XOR (^)
  12. 100
  13. 101
  14. ---
  15. 001
  16. ### NOT (~)
  17. 101
  18. ---
  19. 010
  20. ### Shift (>>) and (<<)
  21. 0001_0111 >> 3 = 0000_0010
  22. 0001_0111 << 3 = 1011_1000
  23. # Arithmetic
  24. ### Multiply x by 2<sup>k</sup>
  25. x << k
  26. Example: 5 * 8 = 5 << 3
  27. ### Divide x by 2<sup>k</sup>
  28. x >> k
  29. Example: 20 / 16 = 20 >> 4
  30. ### Mod by 2<sup>k</sup>
  31. x & (2<sup>k</sup>-1)
  32.  
  33. Example: 20 % 16 = 20 & 15
  34. ### Is x power of 2?
  35. (x != 0) && (x & (x - 1)) == 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement