1
\$\begingroup\$

Is it possible to subtract a larger binary number from a smaller one column wise . For example subtracting 1000 from 0111 ? I always use the 2s complement but is it possible to do it column wise ?

\$\endgroup\$
  • \$\begingroup\$ Yes. The very same way as decimal. You subtract the smaller one from the bigger one and add - to the result. Since you don't use 2's complement or similar, there is no special coding for negatives, so you will just have -0001 \$\endgroup\$ – Eugene Sh. Oct 11 '18 at 20:40
1
\$\begingroup\$

If you mean you want to do it by hand like you did in elementary school, then yes. Borrow an imaginary 2 (10b) from the imaginary column to the left of the number. For example, here's your problem:

$$ \begin{matrix} & 0 & 1 & 1 & 1 \\ - & 1 & 0 & 0 & 0 \\ \end{matrix} $$

and here's what you have after borrowing a 2 from the imaginary fifth bit (sixteen's place):

$$ \begin{matrix} & 10 \\ & 0 & 1 & 1 & 1 \\ - & 1 & 0 & 0 & 0 \\ \end{matrix} $$

10b - 1b is 1b, so the answer is 1111b, or -1 in two's complement -- exactly what you'd expect if you subtract 8 from 7.

This still works if you need to borrow from a smaller place. This:

$$ \begin{matrix} & 0 & 0 & 1 & 1 \\ - & 0 & 1 & 0 & 1 \\ \end{matrix} $$

becomes:

$$ \begin{matrix} & 1 & 10 \\ & 0 & 0 & 1 & 1 \\ - & 0 & 1 & 0 & 1 \\ \end{matrix} $$

which is 1110b (-2) -- again, exactly what you'd expect if you subtract 5 from 3.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.