The bit operations {~, &, |, ^} in C operate on integers at each bit of the integer.
So the DeMorgan's Identities just verified for single bit operands still hold for integers:
If x and y are C integers then
~(x & y) = (~x) | (~y) ~(x | y) = (~x) & (~y) ~~x = x
Example with 8 bit integers x and y
Verifying that ~(x & y) = (~x) | (~y)
x | 0110 0011 |
---|---|
y | 1101 0111 |
x & y | 0100 0011 |
~x | 1001 1100 |
~y | 0010 1000 |
(~x) | (~y) | 1011 1100 |
~(x & y) | 1011 1100 |