Bit-wise Operators
Some applications require operations to be done on dissimilar bits of a byte separately. Bit-wise operators offer a facility to do just that. There are various bit-wise operators:
Unary Operator: One's Complement Operator(')
This operator is a unary operator that causes the bits of its operand to be inverted, i.e. 1 become 0 and 0 becomes 1. For instance, to see the largest possible number, which can be kept in an unsigned integer, a zero can be assigned to it. All the bits in this word will be zeros. When the one's complement operator is used on this word, all the bits will be inverted to ones, giving the largest possible number. The program to show this conversion is below:
main()
{
unsigned u = 0;
printf("Value before conversion : %d\n",u);
u = ~u;
printf("Value After conversion : %d\n",u);
}