November 2013
Beginner
325 pages
9h 47m
English
For completeness, here are the other bitwise operators. These are less commonly used in Objective-C but good to know.
You can exclusive-or (XOR) two bytes together to create a third. A bit in the third byte is 1 if exactly one of the corresponding bits in the input bytes is 1.
Figure 38.5 Two bytes bitwise-XORed together
This is done with the ^ operator. Add to main.c:
unsigned char e = a ^ b;
printf("Hex: %x ^ %x = %x\n", a, b, e);
printf("Decimal: %d ^ %d = %d\n", a, b, e);
return 0;
}
When you run it you will see:
Hex: 3c ^ a9 = 95 Decimal: 60 ^ 169 = 149
This operator ...
Read now
Unlock full access