Bitwise negation operator ~

The ~ (bitwise negation) operator yields the bitwise complement of the operand. In the binary representation of the result, every bit has the opposite value of the same bit in the binary representation of the operand. The operand must have an integral type. The result has the same type as the operand but is not an lvalue.

Suppose x represents the decimal value 5. The 16-bit binary representation of x is:

0000000000000101

The expression ~x yields the following result (represented here as a 16-bit binary number):

1111111111111010

Note that the ~ character can be represented by the trigraph ??-.

The 16-bit binary representation of ~0 is:

1111111111111111

Related information



[ Top of Page | Previous Page | Next Page | Contents | Index ]