Binary Subtraction Calculator

This calculator subtracts one binary number from another and shows the full working, not just a bare result. It suits computer science students, programmers and anyone learning number systems who wants to understand how subtraction actually happens at the bit level, since this underpins how computers handle arithmetic internally. You enter two binary numbers: the minuend (A), the number being subtracted from, and the subtrahend (B), the number being taken away, using only the digits 0 and 1 and any number of bits. The calculator instantly returns the binary result of A minus B, the signed decimal equivalent, and the decimal value of each input, updating live as you type. Below the results, a step-by-step working panel walks through the borrow method column by column from right to left, showing where each borrow is taken and passed along, plus a full breakdown table of the calculation. A second panel then verifies the same answer using the two's complement method, computing the one's complement of B, adding 1, adding that to A, and confirming the two approaches agree. Watch the sign: if B is larger than A the result is negative, and the calculator flags this clearly, showing the true magnitude in two's complement notation, matching how signed integers are actually stored in computer hardware.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
Advertise on this page
Standard method  Borrow method for binary subtraction; verified by two's complement addition.

1. Enter Binary Numbers

Enter binary digits (0 and 1 only)
Enter binary digits (0 and 1 only)

2. Quick Reference

Binary subtraction rules (one column at a time):

A − BResultBorrow
0 − 000
1 − 010
1 − 100
0 − 111 (borrow)

When you borrow, the column to the left loses 1; the current column gains 2 (binary base).

Result: A − B

Binary Result
1000
A − B in binary
Decimal Result
8
Signed decimal value
A (decimal)
13
Minuend
B (decimal)
5
Subtrahend

Step-by-Step Borrow Method

Enter two binary numbers above to see working.

Full Breakdown

Minuend A (binary)1101
Subtrahend B (binary)0101
A (decimal)13
B (decimal)5
A − B (decimal)8
A − B (binary)1000

Two's Complement Verification

B (binary, padded)00101
One's complement of B11010
Two's complement of B11011
A + two's complement(B)01000
Carry out discardedYes (1 discarded)
Verified result1000
Result: Enter two binary numbers above.

How Binary Subtraction Works

Binary subtraction follows the same column-by-column process as decimal subtraction, but with only two digits: 0 and 1. The four possible single-bit subtractions are straightforward except for 0 minus 1, which requires a borrow from the next column to the left.

When you borrow in binary you take 1 from the next higher bit. That higher bit loses 1, but the current column gains 2 (because each position is worth twice the one to its right). So 10 (binary 2) minus 1 (binary 1) = 1, with a borrow of 1 passed to the left.

Worked Example: 1101 − 0101

Default inputs: A = 1101 (decimal 13), B = 0101 (decimal 5). Expected result: 1000 (decimal 8).

Column (bit position)Bit 3 (8s)Bit 2 (4s)Bit 1 (2s)Bit 0 (1s)
A1101
B0101
Borrow in0000
Result bit1000

Column 0 (rightmost): 1 − 1 = 0, no borrow. Column 1: 0 − 0 = 0, no borrow. Column 2: 1 − 1 = 0, no borrow. Column 3: 1 − 0 = 1. Result: 1000 (binary) = 8 (decimal). This matches 13 − 5 = 8.

The Borrow Method in Detail

Process each column from right (least significant bit) to left (most significant bit):

  1. Subtract the B bit and any borrow-in from the A bit.
  2. If the result is 0 or 1, write it as the result bit with no borrow-out.
  3. If A bit minus B bit minus borrow-in is −1: write result bit 1 and set borrow-out to 1 (you borrowed 2, spent 1, gave back 1).
  4. If A bit minus B bit minus borrow-in is −2: write result bit 0 and set borrow-out to 1.
  5. Continue to the next column to the left.

If after processing all columns there is still a borrow-out of 1, the result is negative. The true magnitude is the two's complement of the binary result.

Two's Complement Method

Computers typically implement subtraction A − B as A + (two's complement of B). The two's complement of B is formed by inverting all its bits (one's complement) and adding 1. The two's complement of a number N equals −N in signed binary representation, so adding it to A gives A − B. Any carry beyond the bit width is discarded for same-width arithmetic. This calculator shows both methods and confirms they agree.

Negative Results

If A is smaller than B, the result is negative. The calculator displays the signed decimal result (e.g. −3) and shows the binary representation as the two's complement of the magnitude. In signed integer arithmetic (as used in programming languages and computer hardware), negative numbers are stored in two's complement form: the most significant bit is 1 for negative, 0 for positive.

Related Calculators

Method: Direct borrow-method binary subtraction working column by column from least significant bit to most significant bit. Two's complement verification by inverting all bits of B and adding 1, then adding to A. Both methods produce the same signed decimal result.

This calculator works with unsigned binary integers of any length. Results are exact for all inputs. The decimal equivalents treat the inputs as unsigned positive integers; the subtraction result may be negative if B is greater than A.