What does bitwise complement (~) do?

Study for the Computer Programming Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

What does bitwise complement (~) do?

Explanation:
Bitwise complement flips every bit in the value. For each position, 0 becomes 1 and 1 becomes 0. This operator is commonly described as flipping every bit, which exactly captures what it does to the binary representation. For example, on an 8-bit value, 00001010 becomes 11110101. In two’s complement, this operation is equivalent to -x - 1, illustrating that it’s a bitwise not, not a shift or a multiplication. It does not move bits around or scale the number, which rules out shifting or multiplying.

Bitwise complement flips every bit in the value. For each position, 0 becomes 1 and 1 becomes 0. This operator is commonly described as flipping every bit, which exactly captures what it does to the binary representation. For example, on an 8-bit value, 00001010 becomes 11110101. In two’s complement, this operation is equivalent to -x - 1, illustrating that it’s a bitwise not, not a shift or a multiplication. It does not move bits around or scale the number, which rules out shifting or multiplying.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy