3
$\begingroup$

$$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

$\endgroup$
5
  • $\begingroup$ Did you write the result correctly (as decimal)? $\endgroup$ Commented Mar 25, 2013 at 1:20
  • $\begingroup$ As decimal, it's impossible. Did you mean binary $-1001$? That's what I get, binary, i.e., in decimal terms $-9_{10}$ $\endgroup$ Commented Mar 25, 2013 at 1:21
  • $\begingroup$ Are you sure the answer is $-1004$? Because if the answer is supposed to be in binary, you can't have a $4$ digit in the answer. Only $0$s and $1$s are allowed. $\endgroup$ Commented Mar 25, 2013 at 1:21
  • $\begingroup$ The answer can't be $-1004$ in decimal either, because $101110$ is even and $110111$ is odd. $\endgroup$ Commented Mar 25, 2013 at 1:24
  • $\begingroup$ Sorry, edited. -1001 $\endgroup$ Commented Mar 25, 2013 at 1:32

4 Answers 4

5
$\begingroup$

$$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)

$\endgroup$
10
  • $\begingroup$ How come when i two's complement 110111 and do addition it does not give me your answer? $\endgroup$ Commented Mar 25, 2013 at 1:35
  • $\begingroup$ do you get two's complement of 110111 = 001001? $\endgroup$ Commented Mar 25, 2013 at 1:36
  • $\begingroup$ 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$ $\endgroup$ Commented Mar 25, 2013 at 1:43
  • $\begingroup$ So that's what I missed. I got halfway basically. I didn't know that you have to perform two's complement twice $\endgroup$ Commented Mar 25, 2013 at 1:46
  • $\begingroup$ So if there is a leading one after binary subtraction using 2s complement, you have to do 2s complmenent again? $\endgroup$ Commented Mar 25, 2013 at 1:46
2
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ +1 Hmmm...I think I remember this question. Rings a bell...;-) $\endgroup$ Commented Apr 14, 2013 at 1:02
  • $\begingroup$ Yeah - I have forgotten about 100000 dollars worth of my formal education! :-) Now I understand what the real world does to a person! $\endgroup$ Commented Apr 14, 2013 at 1:05
1
$\begingroup$

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\,$

$\endgroup$
2
  • $\begingroup$ Nice Don. This one doesn't have .... at the end. +1 :D $\endgroup$ Commented Mar 25, 2013 at 7:55
  • $\begingroup$ Hehe...indeed it doesn't @BabakS. since the OP alreadu knew the answer so it was only a matter of showing him my idea. $\endgroup$ Commented Mar 25, 2013 at 9:47
0
$\begingroup$

$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$.

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.