3

$$101110 - 110111$$

Did the 2's complment and cannot get to the answer. The answer is apparently $$-1001$$

I did 2's complment on the $$110111$$ and performed addition but did not get to the answer. But I heard that I have to "zero-fill" before i do it or something

Aaron
  • 551

4 Answers4

5

$$101110 - 110111 = 101110 + 001001 = 110111$$ with $110111$ being in two's complement (since it has a leading $1$, hence, equivalent to binary $-001001 \; = \;-1001$

The trick I use to go back and forth from two's complement is to switch ALL digits (reverse $1\to 0, 0 \to 1$, then add one bit $1$ ($+000001$ in this case)

amWhy
  • 209,954
  • How come when i two's complement 110111 and do addition it does not give me your answer? – Aaron Mar 25 '13 at 01:35
  • do you get two's complement of 110111 = 001001? – amWhy Mar 25 '13 at 01:36
  • I take 110111, replace all 1's with 0's, all zero's with 1's, and add one bit: step 1: $110111 \to 001000$. Second step: $001000 + 000001 = 001001$. Then add $001001$ to 101110, getting 110111. But the leading $1$ indicates it's negative in two's complement, so we need to perform the two's complement (in reverse, exact same procedure to get it's magnitude), but prefixing it with $-$ sign: $110111\to 001000 + 1 \to -1001$ – amWhy Mar 25 '13 at 01:43
  • So that's what I missed. I got halfway basically. I didn't know that you have to perform two's complement twice – Aaron Mar 25 '13 at 01:46
  • So if there is a leading one after binary subtraction using 2s complement, you have to do 2s complmenent again? – Aaron Mar 25 '13 at 01:46
  • Yes, the leading one tells means you need to perform the two's complement again, exactly! Got it? – amWhy Mar 25 '13 at 01:46
  • So, no leading 0, it's fine as it is. Leading 1, perform 2s complement again? – Aaron Mar 25 '13 at 01:47
  • Yes, exactly, but with the leading $1$, remember to prefix with a negative sign after doing two's complement again. – amWhy Mar 25 '13 at 01:48
  • Got ya. Thanks for the great explanation. – Aaron Mar 25 '13 at 01:50
  • You're welcome, Aaron! – amWhy Mar 25 '13 at 01:51
2

Convert the subtacthend to two's complement and add:

101110−110111 = 101110 + 001001 = 110111

Now, we have a 1-bit as the MSB, telling us that this is a negative number in 2's complement form, so take the two's complement and keep the negative sign.

Thus, we have ( - 001000 + 1 ) = -1001.

Amzoti
  • 56,093
  • +1 Hmmm...I think I remember this question. Rings a bell...;-) – amWhy Apr 14 '13 at 01:02
  • Yeah - I have forgotten about 100000 dollars worth of my formal education! :-) Now I understand what the real world does to a person! – Amzoti Apr 14 '13 at 01:05
1

Well, when I have to substract a bigger number from a smaller one I just flip over the numbers , make the substraction and change sign, say:

$$12-34 =-(34-12)=-22$$

Why not do the same here? Remember: in binary, $\,1-1=0\;,\;1-0=1\;,\;\,0-1=1$...and we carry one, etc. , so:

$$110111-101110 \Longrightarrow\begin{cases}110111\\-\\101110\\........\\001001\end{cases}$$

and now change sign: $\, 101110-110111 =-1001\,$ , and in decimal: $\,46-55=-9\,$

DonAntonio
  • 211,718
  • 17
  • 136
  • 287
0

$110111$ is correct after performing the addition. The leftmost bit is a $1$, indicating that it's a negative number. Use the two's complement on $110111$ to get $001001$, then remove the leading $0$s and add the negative to get $-1001$.

badjr
  • 1,116