Binary Subtraction Calculator

Enter two binary numbers to subtract the second from the first.

Result

10010
18
45
27

How it is calculated

Each field must contain only the digits 0 and 1: no spaces, no 0b prefix, no minus sign. The tool converts both numbers to integers, computes difference = a − b and writes the result back in binary. It also prints a, b and the difference in decimal, with thousands separators, so you can cross-check the work. The first number must be greater than or equal to the second; if b is larger the result would be negative, and the tool shows no result rather than a two's complement value. Equal numbers give 0, and leading zeros are accepted and dropped. Each number may have at most 63 significant bits, which keeps every digit exact; longer numbers show no result.

Worked example

Subtract b = 11011 from a = 101101. In decimal, 101101 is 32 + 8 + 4 + 1 = 45 and 11011 is 16 + 8 + 2 + 1 = 27. The difference is 45 − 27 = 18. Converting back, 18 = 16 + 2, which is 10010 in binary. So the binary difference is 10010 and the decimal difference is 18. A column check agrees: 1 − 1 = 0 in the rightmost column, then 0 − 1 needs a borrow of 2 from the next column, and so on until 10010 appears.

Try this example →

Common mistakes

  • Putting the numbers in the wrong order. The tool computes first minus second, and a smaller first number gives no result.
  • Typing a prefix or a digit other than 0 and 1, such as 0b101 or 102. Such input is rejected and no result appears.
  • Entering ordinary decimal numbers such as 45 and 27. They contain digits other than 0 and 1, and a number like 101 is read as binary five, not one hundred and one.
  • Forgetting the borrow value in column subtraction. In binary you borrow 2, not 10, from the next column.
  • Pasting a bit string longer than 63 significant bits. The tool shows no result for it instead of an approximate one.

About this calculator

Subtracting one binary number from another follows the same borrowing logic as decimal subtraction, just with only two digits to work with: when a bit needs to borrow, it borrows a value of 2 from the next column instead of 10, since binary is base 2. So 10 (binary, = 2 in decimal) minus 1 requires borrowing, producing 01 (= 1 in decimal). Digital circuits typically avoid direct borrowing altogether and instead compute subtraction by adding the two's complement of the number being subtracted, which turns subtraction into addition — the same operation the hardware already needs for addition.

This calculator is a common reference for computer science and digital logic students working through binary arithmetic by hand before trusting a computer to do it, and for anyone debugging low-level code, checksums, or bitwise operations who needs to verify a subtraction result in binary. Showing both the binary difference and its decimal equivalent side by side makes it easy to catch a borrowing mistake.

Enter two binary numbers and the calculator subtracts the second from the first, in both binary and decimal.

Was this helpful?

You can pick up to 3 reactions.

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators