Binary Subtraction Calculator – Free

This binary subtraction calculator takes two base-2 whole numbers, subtracts the second from the first, and prints the difference in both binary and decimal.

How to use the Binary Subtraction Calculator tool

  1. Enter the number to subtract from in the First binary number field.
  2. Enter the amount to take away in the Second binary number field.
  3. Select Subtract. The Result box shows a Binary line and a Decimal line.
  4. Select Copy to take both lines, or Example to run 1011 minus 11.

How binary subtraction works

Subtraction in base 2 follows the column method you learned for decimal, with only four cases: 0 - 0 = 0, 1 - 0 = 1, 1 - 1 = 0, and 0 - 1 = 1 with a borrow from the next column to the left. A borrow is worth 2 in the column that receives it, and the column that lends it loses 1.

Hardware usually avoids borrowing. An adder computes A - B as A plus the two's complement of B and throws away the final carry. Both routes give the same difference.

Worked example: 101101 minus 1111

Line up the numbers on the right and pad the shorter one: 101101 and 001111. Working from the rightmost column: 1 - 1 = 0. Then 0 - 1 needs a borrow and leaves 1. The next three columns each have a borrow to repay and each leaves 1. The last column is 1 - 0 minus the borrow, which is 0.

Reading the columns from left to right gives 011110. The calculator drops the leading zero and reports 11110, which is 30. In decimal the same sum is 45 - 15.

First binary number:   101101
Second binary number:  1111

Binary: 11110
Decimal: 30

Negative results and negative inputs

When the second number is larger, the calculator returns a true negative value with a minus sign. For 11 minus 1011 the output is Binary: -1000 and Decimal: -8. It does not wrap the answer into a fixed-width two's complement pattern such as 11111000, because no word size is involved.

Either operand may itself carry a leading minus sign. Subtracting a negative number adds its magnitude, so 1000 minus -11 gives 1011. If you need the wrapped pattern for a register, take the magnitude to the Binary Two's complement Converter and enter it at the register width.

Accepted input and limits

Both fields are required. The arithmetic uses arbitrary-precision integers, so long operands are subtracted exactly.

  • Digits 0 and 1 only, with an optional leading minus sign and an optional 0b prefix.
  • No spaces inside a number. 1010 1 is rejected with an Invalid base-2 digit message.
  • Whole numbers only. A binary point is treated as an invalid digit.
  • Each field can hold up to 4,096 characters.
  • An empty field gives the message: Enter a base-2 whole number.

Frequently asked questions

How do you subtract binary numbers by hand?

Align the numbers on the right and subtract column by column from the right. When the top bit is 0 and the bottom bit is 1, borrow from the next column, write 1, and remember to take 1 off that next column.

What happens if the second number is bigger than the first?

You get a negative difference shown with a minus sign, for example -1000 for 11 minus 1011. The decimal line shows -8. The tool does not convert the result to two's complement.

Can I see each borrow step?

This calculator prints only the final difference. The Binary Borrow Calculator on this site takes the same two fields and lists the borrow in and borrow out for every bit position.

Why do I get an Invalid base-2 digit message?

One of the fields contains something other than 0 and 1. The usual causes are a space inside the number, a decimal digit such as 2, a plus sign, or a binary point. The message names the first offending character.

Is there a limit on operand size?

Each number can be up to 4,096 characters long, counting a minus sign and 0b prefix if present. Results are exact at that size because the calculator does not use floating point.

Related tools