Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. /*
  2. * File: bits.c
  3. *
  4. * Description: Bit manipulation examples
  5. *
  6. */
  7.  
  8. #include <stdio.h>
  9.  
  10. int main()
  11. {
  12. int a = 15; // 0b1111
  13. int b = 5; // 0b101
  14.  
  15.  
  16. // Using bitwise and on a, b returns an int with the common bits set. in
  17. // this case, result will be 5, or 0b101
  18. int result = a & b;
  19.  
  20. printf("a: %d\nb: %d\na & b: %d\n", a, b, result);
  21. /* Prints:
  22. * a: 15
  23. * b: 5
  24. * a & b : 5
  25. */
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement