What is the Binary Subtraction Calculator?
This tool subtracts one binary (base-2) number from another and shows the answer in both binary and decimal. Binary uses only the digits 0 and 1, where each position represents a power of two. Subtracting binary numbers by hand requires borrowing across columns, which is error-prone — this calculator does it instantly and verifies the result against the decimal arithmetic.
How to use it
Enter the first binary number (the minuend) and the second binary number (the subtrahend), using only 0s and 1s. Press calculate to see the binary difference, along with the decimal value of each input and of the result. If the second number is larger, the result is shown as a negative binary value (with a leading minus sign).
The formula explained
The simplest reliable method is to convert each binary string to a decimal integer, perform ordinary subtraction, then convert the difference back to binary:
$$\text{result} = \text{toBinary}\left( \text{parseBinary}(a) - \text{parseBinary}(b) \right)$$
For example, the binary number 1010 equals \(1\cdot8 + 0\cdot4 + 1\cdot2 + 0\cdot1 = 10\) in decimal. This avoids the manual borrowing process while producing identical results.
Worked example
Subtract 11 from 1010. First convert: \(1010_2 = 10_{10}\) and \(11_2 = 3_{10}\). Then $$10 - 3 = 7.$$ Converting 7 back to binary gives \(111_2\). So \(1010 - 11 = \) 111.
How to Subtract Binary by Hand (Borrowing Method)
Direct binary subtraction works just like decimal subtraction, but in base 2 each column holds only a 0 or 1. The key idea is the borrow: when you must subtract 1 from 0, you borrow from the next column to the left, turning the current column into \(10_2\) (which is 2 in decimal), so \(10_2 - 1_2 = 1_2\).
- Align the numbers on the right. Write the larger value (the minuend) on top and the smaller value (the subtrahend) below it, lining up the least-significant bits. Pad the shorter number with leading zeros so both have the same width.
- Work right to left, one column at a time. In each column compute top bit minus bottom bit.
- Apply the column rules: \(0-0=0\), \(1-0=1\), \(1-1=0\), and \(0-1\) needs a borrow.
- The borrow rule: for \(0-1\), borrow 1 from the next column to the left. The current column becomes \(10_2 - 1 = 1\), and you reduce the borrowed-from column by 1 (if that column is itself 0, you must borrow again, chaining leftward).
- Read the result from the bottom row, dropping any leading zeros.
Worked example: \(1010_2 - 0011_2\). Both are padded to four bits. Decimal check: \(10 - 3\).
- Column 0 (rightmost): top 0, bottom 1 → \(0-1\) needs a borrow. Borrow from column 1, giving \(10_2 - 1 = 1\). Result bit = 1. Column 1's top bit drops from 1 to 0.
- Column 1: after lending, top is 0, bottom is 1 → \(0-1\) needs a borrow. Borrow from column 2, giving \(10_2 - 1 = 1\). Result bit = 1. Column 2's top bit drops from 0... it is 0, so the borrow chains to column 3, making column 2 read \(10_2\) then lending 1 to leave 1.
- Column 2: after the chained borrow it holds 1, bottom is 0 → \(1-0=0\). Result bit = 0.
- Column 3: top was 1, but it lent 1 to column 2, leaving 0; bottom is 0 → \(0-0=0\). Result bit = 0.
Reading bottom-to-top by column gives \(0111_2\), i.e. 111\(_2\), which equals \(7\) in decimal — matching \(10 - 3 = 7\).
More Worked Examples
Each example shows the binary subtraction and its decimal equivalent so you can verify the arithmetic.
| Binary subtraction | Decimal check | Result (binary) | Result (decimal) |
|---|---|---|---|
| \(1101_2 - 101_2\) | \(13 - 5\) | 1000\(_2\) | 8 |
| \(11_2 - 1010_2\) | \(3 - 10\) | \(-111_2\) | \(-7\) |
| \(110_2 - 110_2\) | \(6 - 6\) | \(0_2\) | 0 |
Example 1 — \(1101_2 - 101_2\). Pad the subtrahend to \(0101_2\). Column by column from the right: \(1-1=0\); \(0-0=0\); \(1-1=0\); \(1-0=1\). That gives \(1000_2 = 8\), confirming \(13 - 5 = 8\).
Example 2 — \(11_2 - 1010_2\) (negative result). Here the subtrahend (\(10\)) is larger than the minuend (\(3\)), so the answer is negative. Swap and subtract the smaller from the larger: \(1010_2 - 0011_2 = 0111_2 = 7\), then restore the sign to get \(-111_2 = -7\). This matches \(3 - 10 = -7\).
Example 3 — \(110_2 - 110_2\) (equal values). Every column subtracts to 0 with no borrows: \(0-0\), \(1-1\), \(1-1\) all give 0, so the difference is \(0_2 = 0\).
Key Terms
- Minuend
- The number being subtracted from — the value written on top. In \(1010_2 - 11_2\), the minuend is \(1010_2\).
- Subtrahend
- The number being subtracted — the value written underneath. In \(1010_2 - 11_2\), the subtrahend is \(11_2\).
- Difference
- The result of the subtraction: \(\text{minuend} - \text{subtrahend}\).
- Borrow
- When a column requires \(0-1\), a 1 is taken from the next-higher column so the current column becomes \(10_2\) (value 2), allowing \(10_2 - 1 = 1\). The borrowed-from column is reduced by 1, and the borrow may chain further left if that column is also 0.
- Base-2 / Binary
- A positional number system using only the digits 0 and 1, where each place value is a power of two (\(\dots, 8, 4, 2, 1\)).
- Bit (binary digit)
- A single base-2 digit, either 0 or 1. A group of bits represents a larger number; e.g. \(1010_2\) has four bits.
- Two's complement
- A common way computers represent signed integers. A negative value is formed by inverting all bits of its magnitude and adding 1, which lets subtraction be performed as addition of the negated number within a fixed bit width.
- Sign-magnitude
- An alternative signed representation in which the leftmost bit indicates the sign (0 = positive, 1 = negative) and the remaining bits give the magnitude. Simple to read but it has two encodings of zero and is less convenient for arithmetic than two's complement.
FAQ
Can the result be negative? Yes. If the subtrahend is larger, the calculator returns a negative binary value such as -101.
What if I enter an invalid character? Only the digits 0 and 1 are valid binary digits. Any non-binary input is treated as 0.
Is this the same as two's complement subtraction? The decimal value matches, but this tool shows a sign-magnitude result (a minus sign) rather than a fixed-width two's complement representation.