One's Complement Operator: ~
The one's complement operator, sometimes called the "bitwise complement" or "bitwise NOT" operator, produces the bitwise one's complement of its operand. The operand must be of integral type. This operator performs usual arithmetic conversions; the result has the type of the operand after conversion.
For related information, see logical-NOT, addition, bitwise-AND, bitwise-exclusive-OR, and bitwise-inclusive-OR.
Example
In the following example, the new value assigned to y is the one's complement of the original unsigned short value:
// Example of the one's complement operator
unsigned short y = 0xAAAA; // value of y is 0xAAAA
y = ~y; // value of y is 0x5555