The bitwise complement operator (~) sets all 1
bits in its operand to 0
in the result and sets all 0
bits to 1
in the result—otherwise referred to as “taking the one’s complement of the value.” In Fig. 20.8, line 40 assigns variable number1
the value 21845
(00000000 00000000 01010101 01010101
). When the expression ~number1
evaluates, the result is (11111111 11111111 10101010 10101010
).
3.21.158.148