November 2013
Beginner
325 pages
9h 47m
English
You can also bitwise-AND two bytes together to create a third. In this case, a bit on the third byte is 1 only if the corresponding bits in the first two bytes are both 1.
Figure 38.4 Two bytes bitwise-ANDed together
This is done with the & operator. Add the following lines to main.c:
#include <stdio.h>
int main (int argc, const char * argv[])
{
unsigned char a = 0x3c;
unsigned char b = 0xa9;
unsigned char c = a | b;
printf("Hex: %x | %x = %x\n", a, b, c);
printf("Decimal: %d | %d = %d\n", a, b, c);
unsigned char d = a & b;
printf("Hex: %x & %x = %x\n", a, b, d);
printf("Decimal: %d & %d = %d\n", a, b, d); return ...Read now
Unlock full access