Beginner

Binary Subtraction Calculator — Subtract Binary Numbers

Enter two binary numbers A and B to compute A − B. The calculator applies the two's complement method step by step and shows the result in binary, decimal, and hex.
Binary digits (0 and 1 only)
Binary digits (0 and 1 only)
A − B (decimal)
9

Binary: 1001 • Hex: 0x9

A (decimal)
14
B (decimal)
5
Difference (binary)
1001
Difference (hex)
0x9
Two's complement subtraction: A − B = A + (−B)
1

Minuend A

01110
2

Subtrahend B

00101
3

Step 1 — Flip all bits of B (one's complement)

11010
4

Step 2 — Add 1 to get two's complement of B

11011
5

Step 3 — A + two's complement of B (ignore carry-out)

01001
=

Result A − B

1001
Step by step
  1. 1

    A in decimal

    14
  2. 2

    B in decimal

    5
  3. 3

    A − B

    14 − 5 = 9
    Computed via two's complement: A + (~B + 1), discarding any carry out.
0246810121416BA−BAB, difference, and A on the number line
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

Binary subtraction A − B uses two's complement: flip all bits of B, add 1, then add A and discard any carry out. This converts subtraction into addition, which is all a digital adder needs. Enter two binary numbers above to see the step-by-step working and the result in binary, decimal, and hex.

Formula
A − B = A + two's_complement(B) where two's_complement(B) = (~B) + 1 (within the bit width)
How this is calculated

Binary subtraction is most reliably computed using two's complement, the same method used by every modern processor. Instead of borrowing, you negate B by flipping all its bits (one's complement) and adding 1, then add the result to A. Any carry out of the most-significant bit is discarded, and the remaining bits give A − B directly.

The three steps are: (1) Flip every bit of B to form the one's complement; (2) Add 1 to get the two's complement, which is the additive inverse of B within the chosen bit width; (3) Add A to the two's complement of B, keeping only the w-bit result. If A ≥ B the answer is positive and reads directly. If A < B the answer in unsigned terms wraps around the modular arithmetic of the bit width — the true signed result is then negative.

This calculator uses arbitrary-precision integers (JavaScript BigInt) and displays the true signed difference, so you can subtract any-length binary operands without worrying about fixed word sizes or overflow.

Frequently asked questions

Two's complement is the standard way computers represent negative integers and perform subtraction using only an adder circuit. To negate a number, flip every bit (one's complement) and add 1. Adding A to the two's complement of B gives A − B, and any carry out of the top bit is discarded.

The true arithmetic difference is negative. Within a fixed bit width the unsigned result wraps (modular arithmetic), but this calculator uses signed arbitrary precision and reports the correct negative difference directly.

One's complement simply flips every bit of the number. Two's complement goes one step further and adds 1, eliminating the ambiguous negative-zero that one's complement produces. Modern hardware exclusively uses two's complement.

Also known as

subtract binary numbers
binary subtraction with borrow
twos complement subtraction
binary minus calculator
ones complement binary
binary difference calculator
binary arithmetic subtraction

APA

TG we-Calculate Editorial Team. (2026). Binary Subtraction Calculator — Subtract Binary Numbers [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/binary-subtraction-calculator

Chicago

TG we-Calculate Editorial Team. "Binary Subtraction Calculator — Subtract Binary Numbers." TG we-Calculate. 2026. https://we-calculate.com/calculator/binary-subtraction-calculator.

IEEE

TG we-Calculate Editorial Team, "Binary Subtraction Calculator — Subtract Binary Numbers," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/binary-subtraction-calculator

BibTeX

@misc{wecalculate_binary_subtraction_calculator, title = {Binary Subtraction Calculator — Subtract Binary Numbers}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/binary-subtraction-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?