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.
Binary subtraction rules (one column at a time):
| A − B | Result | Borrow |
|---|---|---|
| 0 − 0 | 0 | 0 |
| 1 − 0 | 1 | 0 |
| 1 − 1 | 0 | 0 |
| 0 − 1 | 1 | 1 (borrow) |
When you borrow, the column to the left loses 1; the current column gains 2 (binary base).
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.
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) |
|---|---|---|---|---|
| A | 1 | 1 | 0 | 1 |
| B | 0 | 1 | 0 | 1 |
| Borrow in | 0 | 0 | 0 | 0 |
| Result bit | 1 | 0 | 0 | 0 |
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.
Process each column from right (least significant bit) to left (most significant bit):
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.
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.
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.
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.
If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.
Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.
Calculate.co.nz is the sister site of CalculatorHub.com, the world's largest calculator website by tool count.
All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.
Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.
Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.
Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.
All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.
About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use
Reviewed and maintained. Last reviewed 2026-07-02 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.
© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.