Electronic – Subtracting a larger binary number from a smaller binary number

binary

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 ?

Best Answer

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.