CSC373/406: C: Bit-Level Operations in C [37/42] Previous pageContentsNext page

Examples using one byte. The examples show the number in base-2 (binary) notation.

 x   == 01000001
~x   == 10111110

 x   == 00000000
~x   == 11111111

 x   == 01101001
 y   == 01010101
 x&y == 01000001

 x   == 01101001
 y   == 01010101
 x|y == 01111101

 x   == 01101001
 y   == 01010101
 x^y == 00111100

the following hold for any x

 ~(~x) == x

Previous pageContentsNext page