Twos complement notation question?

217 Views Asked by At

I have a quick question how do you do the two complement system,

For example say I have in two complement a $6$ which is $0110$ and $3$ which is $0011$ and I want to add

$6+(-3)$ I know what five is in binary but how do I find $-3$ is so that I can add them. That is my question I heard I have to find the complement and add 1.

2

There are 2 best solutions below

6
On BEST ANSWER

Yes, you can "invert" the digits of 3 ($0 \to 1, 1 \to 0$) and ADD 1 to obtain -3 in two's complement. So 0011 is the base two representation of 3, and its complement (-3) is therefore 1100 + 1 = 1101.

Hence $6 + (-3) = 0110 + 1101 = 0011 = 3$ as desired.

2
On

$5$ is $00000101$ and $3$ is $00000011$. The one's complement of $3$ is $11111100$ and the two's complement is one more: $11111101$. Adding gives $(1)00000010$, i.e. $2$ (fortunately).