Binary Calculator: Add, Subtract, Multiply and Divide

A fixed number of bits can overflow, and the answer says so when it does.

result 1001000

in decimal 72
bit 0 1 + 1 0, carry 1
bit 1 0 + 1 + carry 1 0, carry 1
bit 2 1 + 0 + carry 1 0, carry 1
bit 3 1 + 1 + carry 1 1, carry 1
bit 4 0 + 1 + carry 1 0, carry 1
bit 5 1 + 0 + carry 1 0, carry 1
bit 6 the carry out of the top column 1

How to calculate binary addition?

Binary arithmetic is the arithmetic taught for base 10 run on two digits instead of ten: the columns are powers of two, and a column that fills spills into the one on its left.

  1. Write the two values one above the other and line them up from the right, so that each column holds the same place value.
  2. Add the rightmost column first. A column can only hold 0 or 1, so 1 + 1 is written as 0 with a carry of 1 into the next column left, and 1 + 1 + 1 as 1 with a carry of 1.
  3. Move one column left, add the carry from the column before into that sum, and keep going until the columns run out.
  4. Read the answer off from the left, taking in any carry that came out of the top column: for 101101 and 011011 that is 1001000.

What each operation does to a column

The widget fills these four rows for whatever you type in. The last column is a decimal check rather than the answer, so the base-2 working and the base-10 total can be read against each other.

What each operation does to a column
OperationWhat each column does101101 and 011011The same answer in decimal
Addadds the two digits and any carry from the column to its right101101 + 011011 = 100100045 + 27 = 72
Subtracttakes the bottom digit from the top one, borrowing from the left where it has to101101 - 011011 = 1001045 - 27 = 18
Multiplyadds one shifted copy of the first value for every 1 in the second101101 x 011011 = 1001011111145 x 27 = 1215
Dividetakes the divisor out of the running remainder wherever it fits101101 / 011011 = 1 remainder 1001045 / 27 = 1 remainder 18

Worked Example: 101101 + 011011

1001000 is the answer. 101101 plus 011011 is 1001000: 45 and 27 make 72, and every one of the six columns carries.

bit 0 1 + 1 0, carry 1
bit 1 0 + 1 + carry 1 0, carry 1
bit 2 1 + 0 + carry 1 0, carry 1
bit 3 1 + 1 + carry 1 1, carry 1
bit 4 0 + 1 + carry 1 0, carry 1
bit 5 1 + 0 + carry 1 0, carry 1
bit 6 the carry out of the top column 1

101101 + 011011 = 1001000

Each line above is one column, read right to left. The carry never clears: it comes out of all six columns, which is what makes this pair worth following by hand.

What Changes the Answer You Get?

The width you keep the answer at

At a fixed width the carry out of the top column has nowhere to go, so what is stored is the true answer less the range of the width: 101101 plus 011011 is 1001000, but kept in six bits it reads 001000. Set the width control to the width of the wider value and the widget reports the overflow rather than the short answer on its own.

Whether the top bit is a sign

Two's complement lets one addition rule serve both signs: a subtraction is worked as an addition of the second value with every bit flipped and 1 added, and the carry out of the top column is thrown away. Take 101101 from 011011 and the answer is -10010, which a signed eight-bit field holds as 11101110.

Arithmetic, not conversion

This page calculates with binary values rather than converting them: it adds, subtracts, multiplies and divides in base 2, and the decimal printed beside each answer is a check on the arithmetic, not the output.

Frequently Asked Questions

How to subtract in binary?

Take the bottom digit from the top one, column by column, from the right. When the top digit is 0 and the bottom digit is 1, the column borrows 1 from the next column left, which is worth 2 here, so the column subtracts 1 from 10 and writes 1.

How do I multiply binary numbers by 2?

Shift every digit one place left and write a 0 in the new rightmost column, so 1011 becomes 10110. Binary multiplication is shift and add: each 1 in the multiplier copies the other value shifted left by that digit's position, each 0 contributes nothing, and the copies are added.

How to calculate binary division?

Binary long division subtracts the divisor from the running remainder whenever it fits, writing 1 in the quotient when it does and 0 when it does not, and what is left at the end is the remainder. The widget prints the quotient and the remainder as separate figures.

What are the four rules for adding binary numbers?

0 + 0 is 0, 0 + 1 is 1, 1 + 0 is 1, and 1 + 1 is 10, a 0 in the column with 1 carried left. A fifth case turns up once a carry arrives: 1 + 1 + 1 is 11, a 1 in the column with 1 carried.

How do you subtract 111 from 1000 in binary?

The answer is 1. Every column of 1000 above the rightmost one is 0, so the borrow has to run the whole way left before the rightmost column has anything to take from.

The rest of the site is under All tools.

The rest of the family sits on back to the binary converter.

To read a single value rather than compute one, bin to dec by weighted sum.