Binary Subtraction Calculator

Subtract one binary number from another and get the binary difference, its decimal equivalent, and the two's complement form used to represent negative binary values.

Quick Facts

Method
Borrow subtraction, base 2
Equivalent to subtracting the decimal values of A and B, then converting the difference back to binary.
Negative results
Shown in two's complement
Invert every bit of the positive magnitude and add 1 to encode a negative value within a fixed bit width.

Your Results

Calculated
Binary difference (A − B)
-
Base 2, with sign if negative
Decimal difference
-
Same result in base 10
Two's complement
-
Fixed-width binary storage form
Decimal values of A and B
-
Inputs converted to base 10

Ready

Enter two binary numbers and choose a bit width, then press Calculate.

How Binary Subtraction Works

Binary subtraction follows the same place-value logic as subtracting decimal numbers, except every digit (bit) can only be 0 or 1. This calculator computes the exact difference of two binary numbers, shows the result in binary and decimal, and — when the result is negative — displays it in two's complement, the format computers use to store negative binary values in a fixed number of bits.

The borrow method

Working from the rightmost bit, subtract each pair of bits and record a borrow whenever the top bit is smaller than the bottom bit, exactly as in decimal long subtraction. The rules are: 0 − 0 = 0, 1 − 0 = 1, 1 − 1 = 0, and 0 − 1 = 1 with a borrow of 1 taken from the next column to the left. This calculator performs the equivalent operation by converting both binary numbers to decimal (A and B), computing A − B, and converting the difference back to base 2 — the two approaches always agree, because binary is simply base-2 place value.

Two's complement for negative results

When B is larger than A, the true difference is negative, and computers represent that value in two's complement rather than with a minus sign. To find the two's complement of a positive binary number within a fixed bit width: invert every bit (0 becomes 1, 1 becomes 0), then add 1. For example, the 8-bit two's complement of 8 (00001000) is 11111000, which is how a processor register would store −8. This calculator wraps the difference into the selected bit width using modular arithmetic, which produces the identical result.

Choosing a bit width

The bit width only affects the two's complement output — it must be large enough to hold both input values, or the calculator flags the inputs as out of range. Common widths are 4 bits (a nibble, values 0–15), 8 bits (a byte, values 0–255), and 16 bits (values 0–65,535), matching how registers and memory cells are typically sized.

Worked example

11012 (13 in decimal) minus 1012 (5 in decimal) equals 10002 (8 in decimal) — no final borrow remains once the column-by-column subtraction is complete. Reverse the operands (101 − 1101) and the true difference is −8; the calculator reports the magnitude as −1000 in binary and its 8-bit two's complement as 11111000.

Frequently Asked Questions

How do you subtract binary numbers by hand?
Subtract bit by bit from right to left using the same borrow rule as decimal subtraction: 0−0=0, 1−0=1, 1−1=0, and 0−1=1 with a borrow of 1 taken from the next column. This gives the identical answer as converting both numbers to decimal, subtracting, and converting the difference back to base 2.
What is two's complement and why is it used?
Two's complement is how computers represent negative binary numbers within a fixed bit width. To form it, invert every bit of the positive value (0 becomes 1, 1 becomes 0) and add 1. It lets hardware use the same adder circuit for both addition and subtraction, since A − B can be computed as A plus the two's complement of B.
What happens when the subtrahend is larger than the minuend?
The true difference is negative. This calculator shows the magnitude with a minus sign (for example −1000) and also the two's complement encoding at your chosen bit width, which is how that negative value would actually be stored in a processor register.
Can I subtract binary numbers of different lengths?
Yes. Pad the shorter number with leading zeros so both operands line up to the same number of bits before subtracting column by column. Leading zeros never change a binary number's value, so 101 and 0101 represent the same quantity.