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: 1001 • Hex: 0x9
Minuend A
Subtrahend B
Step 1 — Flip all bits of B (one's complement)
Step 2 — Add 1 to get two's complement of B
Step 3 — A + two's complement of B (ignore carry-out)
Result A − B
- 1
A in decimal
14 - 2
B in decimal
5 - 3
A − B
14 − 5 = 9Computed via two's complement: A + (~B + 1), discarding any carry out.
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
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
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
TG we-Calculate Editorial Team. "Binary Subtraction Calculator — Subtract Binary Numbers." TG we-Calculate. 2026. https://we-calculate.com/calculator/binary-subtraction-calculator.
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
@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?
