binary subtraction

854 Views Asked by At

I am trying to solve binary subtraction:

$$11000_2 - 1011_2 = 1001_2$$

I know that it should be $1001_2$, when checking with answer key however I am not sure how it was calculated as I get different result : $1011_2$, as $0-1$ should give $1$.

Thank you for your help in advance!

2

There are 2 best solutions below

3
On BEST ANSWER

Don't forget to "borrow" when subtracting $1$ from $0$.

Here it is in "slow motion:" \begin{array}{c} &1&\not1 ^ 0 & \not0^\color{red}1 & \not0^\color{red}1&^10\\ -&&1 & 0 & 1 & 1\\\hline &&&&&1 \end{array} \begin{array}{c} &\not 1^0&^10 & \color{red}1 & \color{red}1&^10\\ -&&1 & 0 & 1 & 1\\\hline &&1&1&0&1 \end{array}

Note: If the answer key has listed $1001$ as the correct answer, they're wrong... :)

0
On

Computing $1111_2-1011_2$ is easy: you just change each $0$ into $1$ and each $0$ into $1$, getting $0100_2=100_2$. Now adding $1$ is easy as well: you get $101_2$.

I'll leave out the subscript $2$ from now on.

Why is this important? Because you can say $$ 11000-1011=11000+(10000-1011)-10000 $$ and $10000-1011=1+1111-1011=101$ as seen before. Thus we do an addition $$ \begin{array}{rc} 11000&+\\ 101&=\\ \hline 11101 \end{array} $$ and an easy subtraction $$ \begin{array}{rc} 11101&-\\ 10000&=\\ \hline 1101 \end{array} $$

Additions are easier than subtraction, because you carry only to the next column (maybe several times), while borrowing can jump several columns away.

Another example: $1001001-10110$. Compute $111111-010110=101001$, so $1000000=101001+1=101010$. Then $$ \begin{array}{rc} 1001001&+\\ 101010&=\\ \hline 1110011&-\\ 1000000&=\\ \hline 110011 \end{array} $$

Final checks:

  1. $11000_2=24$, $1011_2=11$; $1101_2=13$.
  2. $1001001_2=73$, $10110_2=22$; $110011_2=51$.