The interesting case in binary subtraction is
0 - 1 = 1 with borrow
The subtraction table has the added wrinkle that
0 - 1
triggers a borrow from the bit
position to the left. In elementary
school, borrowing is challenging for some students.
Imagine the school mantra applied to \( 25 - 7 \):
"Five minus seven becomes fifteen minus seven
by borrowing ten from the next subtrahend digit to the left,
reducing it by one." Out comes \( 18 \)!
When we reach left one bit position to borrow, we get
\( 2 \), or 10
in binary.
-| 0 1 -+------- 0| 0 b1 1 with borrow 1| 1 0
Later on, we will look at another way to subtract,
but it's useful to carry the operation out in our
paper-and-pencil manner to get a feel for binary
operations.
Each b
indicates a borrow from that
bit position.
bbbbb 01100100 100 - 00001101 - 13 ---------- ---- 01010111 87
You might be thinking that anyone can subtract \( 13 \) from \( 100 \). But how about the other way around? It's just more subtract-with-borrow, with the extra twist that we get a free borrow from beyond the leftmost bit, if needed. Here it is:
bbb 00001101 13 - 01100100 -100 ---------- ---- 10101001 169 = 256 - 87
When we borrow from the left,
it is as though we have added \( 2^{8} = 256 \)
to the result. What
mathematically ought
to be \( -87 \) is actually
\( 256 - 87 = 169 \) or
01010001
in
the byte.
We'll see in the later pages how easy it is to have negative numbers in bytes, too.