What bitwise operation can make positive numbers negative, and vice versa?
What bitwise operation can make positive numbers negative, and vice versa?
~ the NOT operator.
~5 -> -6
0101 -> 1010 = -8 + 2
This is the same when you involve multiple zeroes, because the leftmost Bit will be a negative number.
0000 0101 -> 1111 1010 = -128 + 64 + 32 + 16 + 8 + 2 = -128 + 122 = -6