C examples for Operator:Bit Operator
The unary operator, ~, flips the bits of its operand, so 1 becomes 0, and 0 becomes 1.
#include <stdio.h> int main(void) { /*from www .jav a 2s . c om*/ int x = 13; int y = 6; int z = ~x; // Store 1's complement of x printf("%d",z); return 0; }
After executing this statement, z will have the value 14. The bits are set as follows:
x 0 0 0 0 1 1 0 1 ~x 1 1 1 1 0 0 1 0