Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: bits.c
- *
- * Description: Bit manipulation examples
- *
- */
- #include <stdio.h>
- int main()
- {
- int a = 15; // 0b1111
- int b = 5; // 0b101
- // Using bitwise and on a, b returns an int with the common bits set. in
- // this case, result will be 5, or 0b101
- int result = a & b;
- printf("a: %d\nb: %d\na & b: %d\n", a, b, result);
- /* Prints:
- * a: 15
- * b: 5
- * a & b : 5
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement