I wish to compute $1001_2 - 0110_2$, but I having trouble with how borrowing works. I know that to compute $0 - 1$, we must borrow. So $1001_2$ becomes $0011_2$. Now we have $0011_2 - 0110_2$, but for the second $ 0 - 1$ calculation, what do I do? There is nothing to borrow from.
Binary subtraction confusion $1001_2 - 0110_2$
408 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 2 best solutions below
On
There is a method of subtracting that avoids the whole borrowing scenario. It's called Austrian subtraction.
Your subtraction problem would go like this
\begin{array}{ccccc} & 1 & 0 & 0 & 1 \\ - & 0 & 1 & 1 & 0 \\ \hline \end{array}
You start at the far right and look at $\; \begin{array}{c} 1 \\ \underline 0 \\ \text{?} \end{array}. \;$
- You think $ 1 + \color{red} 0 = \color{red} 1$
- You replace the ? with a $1$.
\begin{array}{ccccc} & 1 & 0 & 0 & 1 \\ - & 0 & 1 & 1 & 0 \\ \hline & & & & 1 \end{array}
Here is where things get different than you are used to. Next you look at $\; \begin{array}{c} 0 \\ \underline 1 \\ \text{?} \end{array}.$
- You think $1 + \color{red} 1 = 1\color{red} 0$
- You replace the ? with a $1$.
- You carry the $1$ (in $1\color{red} 0$) as shown below
\begin{array}{ccccc} & 1 & 0 & 0 & 1 \\ - & 0 & 1^1 & 1 & 0 \\ \hline & & & 1 & 1 \end{array}
Next you look at $\; \begin{array}{l} 0 \\ \underline 1^1 \\ \text{?} \end{array}.$
- You think $0 + 1 + 1 = 10$
- You replace the ? with a $0$.
- You carry the $1$ as before.
\begin{array}{ccccc} & 1 & 0 & 0 & 1 \\ - & 0^1 & 1^1 & 1 & 0 \\ \hline & & 0 & 1 & 1 \end{array}
- You think $0 + 0 + 1 = 1$
- You replace the ? with a $0$.
- You are done.
\begin{array}{ccccc} & 1 & 0 & 0 & 1 \\ - & 0^1 & 1^1 & 1 & 0 \\ \hline & 0 & 0 & 1 & 1 \end{array}
Rather than computing $1001_2 - 0110_2$, we can drop the last place and just focus on $100_2-011_2$ as this is the part that really involve borrowing.
\begin{align}100_2 -011_2&= (1 \times 2^2 + 0 \times 2 + 0 \times1) - (0 \times 2^2 + 1 \times 2 + 1 \times1) \\ &= (1 \times 2^2 + \color{red}{(-1)} \times 2 + \color{blue}2 \times1) - (0 \times 2^2 + 1 \times 2 + 1 \times1)\\ &= (1 \times 2^2 + (-1) \times 2) - (0 \times 2^2 + 1 \times 2 )+ 1 \times1\\ &= ((1\color{red}{-1}) \times 2^2 + (\color{blue}2-1) \times 2) - (0 \times 2^2 + 1 \times 2 )+ 1 \times1\\ &=(0 \times 2^2 + 1 \times 2) - (0 \times 2^2 + 1 \times 2 )+ 1 \times1\\ &=1\end{align}
In general, if you need to borrow from your next neighbor in $d$-ary, subtract $1$ from it and add $d$ to yourself.