Binary basics
Binary subtraction
Borrowing, two's complement and one's complement, step by step. Subtract any two binary numbers and see every borrow.
You need to work out something like 1010 - 0111 by hand. Do it the way you'd subtract decimal numbers: column by column from the right. The one change is that a borrow is worth 2 instead of 10. The four rules are 0 - 0 = 0, 1 - 0 = 1, 1 - 1 = 0, and 0 - 1 = 1 with a borrow from the next column. So 1010 - 0111 = 0011, which is 10 - 7 = 3 in decimal. Computers skip borrowing and add the two's complement instead, and that method is further down.
Key takeaways
| The four rules: 0 - 0 = 0, 1 - 0 = 1, 1 - 1 = 0, and 0 - 1 = 1 with a borrow. | |
| A borrow in binary is worth 2 in the column that receives it, not 10. | |
| Computers subtract by adding: invert B, add 1, add it to A and drop the carry. | |
| With two's complement, no carry out means the answer is negative. | |
| Always pad both numbers to the same width before you invert bits. |
Binary subtraction calculator with steps
Enter two binary numbers. The tool shows the borrow in each column, the result in binary and decimal, and the same subtraction done with two's complement.
The 4 rules of binary subtraction
| Digits | Result | Borrow | Why |
|---|---|---|---|
| 0 - 0 | 0 | no | nothing to take away |
| 1 - 0 | 1 | no | nothing to take away |
| 1 - 1 | 0 | no | one minus one |
| 0 - 1 | 1 | yes | borrow 2 from the left: 2 - 1 = 1 |
The last rule is the only tricky one. Borrowing from the next column gives you 2 in the current column, because each binary place is worth twice the one to its right. The column you borrowed from loses 1, the same way it does in decimal.
Method 1: subtraction with borrowing
Work out 11001 - 01011, which is 25 - 11 in decimal. Write the numbers one above the other with the same number of digits, then go from right to left. Column 1 is the rightmost:
| Column | Top digit | Bottom digit | Borrow in | Result digit | Borrow out |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 0 | 0 | no |
| 2 | 0 | 1 | 0 | 1 | yes |
| 3 | 0 | 0 | 1 | 1 | yes |
| 4 | 1 | 1 | 1 | 1 | yes |
| 5 | 1 | 0 | 1 | 0 | no |
A borrow out of one column becomes the borrow in of the next, and you take it away from the top digit before subtracting. In column 3, for example, the top digit 0 minus the borrow is already below zero, so that column borrows too. Read the result digits from the bottom row up: 01110, which is 14. 25 - 11 = 14, so the answer checks out.

Borrowing across zeros
When the column to the left is 0, the borrow has to travel further, as it does in 1000 - 1 in decimal. In 1000 - 0001, the rightmost column borrows from the next 1 it can find, three places left. Every 0 it passes becomes 1 on the way, so the answer is 0111. The rule of thumb: the borrowed 1 turns into a 0, and every 0 between it and the column you are working on turns into a 1.
Method 2: subtraction with two's complement
Computers subtract by adding. To work out A - B, they turn B into its negative with two's complement and add it to A. The two's complement of B is every bit inverted, plus 1. It works as a negative because B plus its inverted bits is all 1s, and one more rolls over to all 0s once the extra digit is dropped. Here is 1010 - 0111 (10 - 7) in 4 bits:
- Invert 0111 to get
1000. - Add 1 to get
1001. This is -7 in 4-bit two's complement. - Add it to A: 1010 + 1001 =
10011. - The sum has 5 digits. Drop the carry out of the leftmost column and keep 4 bits:
0011, which is 3.
The carry tells you the sign. A carry off the left end means the result is positive or zero. No carry means the result is negative and already written in two's complement. Try 0101 - 1000 (5 - 8): two's complement of 1000 is 1000, and 0101 + 1000 = 1101 with no carry. In 4-bit signed binary, 1101 is -3, and 5 - 8 = -3. The two's complement calculator shows the working for any value and width.

Method 3: one's complement with end-around carry
Some older machines used one's complement, which is the inverted bits without the +1. To subtract, add the one's complement of B to A. If a carry falls off the left, add it back to the right end. For 1010 - 0111: invert 0111 to 1000, then 1010 + 1000 = 10010. Take the carry 1 off the left and add it to 0010, which gives 0011, the same 3 as before.
One's complement has two ways to write zero, 0000 and 1111, so every test for zero has to check both patterns. That extra work is a big reason modern processors use two's complement, which has only one zero.
The three methods side by side
| Method | Steps | Used by | Negative results |
|---|---|---|---|
| Borrowing | subtract column by column, borrow 2 when needed | people working on paper | swap the numbers and add a minus sign |
| Two's complement | invert B, add 1, add to A, drop the carry | almost every processor today | come out directly in two's complement |
| One's complement | invert B, add to A, add the carry back | some older computers | come out inverted |
On paper, use borrowing, because you can see every step. If you're learning how a processor does it, or you need negative results, use two's complement. It wins in hardware because the same adder circuit handles both addition and subtraction. To subtract, the circuit inverts B with XOR gates and sets the first carry in to 1, which adds the 1. The half adder and full adder guide shows that circuit, and the binary calculator shows the borrow row for any subtraction.
Common mistakes
- A digit in your answer isn't 0 or 1. You borrowed 10 out of decimal habit, so 0 - 1 became 9. In binary a borrow is worth 2 in the column that receives it.
- Two's complement gives 000 for 111 - 1, because inverting a lone 1 and adding 1 gives 1 again. Pad the shorter number first, because the inverted bits need the same width as A. As 111 - 001, the two's complement of 001 is 111, and 111 + 111 = 1110. Drop the carry and you get 110, which is 6.
- Your answer has one digit too many, like 10011 for 10 - 7. That leftmost 1 is the carry, and with a fixed width you throw it away.
- You expected -3 and got 13. Both are 1101: it's -3 in 4-bit signed binary and 13 as an unsigned number. Decide which one you mean before you read the result.
Practice problems with answers
| Problem | Answer | Check in decimal |
|---|---|---|
1101 - 0110 | 111 | 13 - 6 = 7 |
10000 - 00011 | 1101 | 16 - 3 = 13 |
11111 - 10101 | 1010 | 31 - 21 = 10 |
101010 - 010111 | 10011 | 42 - 23 = 19 |
0110 - 1001 | -11 | 6 - 9 = -3 |
Check any answer by converting both numbers with the binary to decimal converter, or convert a decimal answer back with the decimal to binary converter.
Questions people ask
What are the rules of binary subtraction?
0 - 0 = 0, 1 - 0 = 1, 1 - 1 = 0, and 0 - 1 = 1 with a borrow of 1 from the next column to the left.
How do you borrow in binary subtraction?
Take 1 from the next column to the left. It is worth 2 in the current column, so 0 - 1 becomes 2 - 1 = 1, and the column you borrowed from is reduced by 1.
What is 1 - 1 in binary?
0, with no borrow. 10 - 1 in binary is 1, because 10 is 2 in decimal.
How do computers do binary subtraction?
They add the two's complement. To work out A - B, the processor inverts every bit of B, adds 1, and adds the result to A using the same adder it uses for addition.
How do you subtract a bigger binary number from a smaller one?
With borrowing, swap them, subtract, and put a minus sign in front. With two's complement, add as usual. If there is no carry out, the result is negative and already in two's complement form.
What is the difference between one's and two's complement subtraction?
One's complement only inverts the bits and needs the carry added back at the end. Two's complement inverts and adds 1, and the carry is dropped.
Keep reading
All posts
Binary basicsMSB and LSB: most and least significant bits, signed integers and overflow
The MSB is the leftmost, highest-value bit and the LSB the rightmost. See what each tells you, how signed integers use the MSB as a sign bit, and how integer overflow wraps values around.9 min read
Binary basicsFloating point numbers explained: why 0.1 + 0.2 is not 0.3
A floating point number is scientific notation in binary. See why 0.1 + 0.2 is 0.30000000000000004, how precise floats are, float vs double, and how to compare floats and handle money.9 min read
Binary basics
