## Sunday, October 24, 2021

Published October 24, 2021 by with 0 comment

# How Do You Subtract Binary Numbers?

What is the value of something like 101001 - 1101?

It's probably easiest to understand this by first going through subtraction of normal (base 10) numbers. What is 119 - 35? You do the following:

• move to 10's digit; 1 - 3 = -2; negative numbers make this hard, so 'borrow' 10 from the 100's digit; now the 10's digit is 11, so 11 - 3 = 8
• 100's digit lost 1 in the top number in the borrowing, so it's now 0; bottom number's 100's digit is 0 also
So you have 0 in the 100's place, 8 in the 10's, and 4 in the 1's, so 84 is the result.

Subtracting binary numbers works identically, except instead of borrowing 10 and using powers of 10 (1's, 10's, 100's, etc.) as places, you use powers of 2 (1's, 2's, 4's, etc.).

Starting with an easy one: 10 - 1 (in binary):
• start with 1's digit; 0 - 1 = -1; negative numbers make this hard, so 'borrow' 2 from the 2's digit; now the 1's digit is 2 - 1 = 1
• move to 2's digit; it lost 1 in the borrowing, so it's now 0; bottom number's 100's digit is 0 also
So you have 0 in the 2's place, and 1 in the 1's place, so the answer is 1. Double-checking, 10 in binary is 2, and 1 is 1, so 10 - 1 in binary is the same as 2 - 1 in normal (base 10) which is obviously 1.

That's it. It works the exact same way as base 10 subtraction except that instead of borrowing 10, you borrow 2.

Now for the original problem: 101001 - 1101
• 1's digit is 1 - 1 = 0
• 2's is 0 - 0 = 0
• 4's is 0 - 1; borrow from the 8's to get 2 - 1 = 1
• 8's had the borrow on the top, so it's now 0 - 1; borrow from the 16's to get 2 - 1 = 1
• 16's had the borrow on the top, so now it's -1 - 0; borrow from the 32's to get 1 - 0 = 1
• 32's had the borrow on the top, so now it's 0 - 0 = 0
So the result is just 11100. Converting that to base 10, that's 28. Checking by converting the original problem, that was 41 - 13, and the answer is also 28.