All answers I seem to find on how to find the 1s (flip the bits of the positive) and the 2s (flip the bits of the positive binary and add 1) complement doesn't seem to answer my question.
My homework assignment asks to find the complement of a negative number.. So instead of starting out with a positive, and needed to find out what its negative is, I am given a negative number and asked to find its complement.
One silly thought is, do I find the positive value binary value, then flip the bits to get my negative number, then flip it again to find my 1s complement of the negative number??
It doesn't matter if your starting number is positive or negative - in a two's complement system,
-x
is the same as~x + 1
. If your original number is positive, the result will be negative, and if the original number is negative, the result will be positive. 8-bit example - binary means 2's complement binary:Note the
-x (binary)
column and the~x+1 (binary)
column are the same.If you need to get the 1's complement of a number, that's just
~x
.