Binary Arithmetic
calculator.
Add, subtract, multiply or divide in base 2, with every carry and borrow shown.
The eights column: 1 + 0 + 1 carried = 10. Write 0 and carry 1. The last carry becomes a new digit on the left. That finishes the sum: 10001.
- Decimal
- 17
- Hex
- 11
- Digits
- 5
3 columns of 4 carried 1. The carry out of the top column made the answer one digit longer. In decimal that is 17, which fits in 8 bits unsigned.
Written working
The eights column: 1 + 0 + 1 carried = 10. Write 0 and carry 1. The last carry becomes a new digit on the left. That finishes the sum: 10001.
Working
- 1Line the numbers up on the right1011 + 0110
- 2Add the ones column1 + 0 = 1 → write 1
- 3Add the twos column1 + 1 = 10 → write 0, carry 1
- 4Add the fours column0 + 1 + 1 = 10 → write 0, carry 1
- 5Add the eights column1 + 0 + 1 = 10 → write 0, carry 1
- 6The last carry becomes a new left digit= 10001
- 7Check in decimal: add up the place values of the 1 bits11 + 6 = 17, and 10001 = 16 + 1 = 17
Keyboard shortcuts
- Click the written working or Tab to it, then press Right arrow for the next column and Left arrow to go back.
- Home clears the page back to the start; End shows the finished working.
- The step slider also moves with the arrow keys once it has focus.
Check a worksheet
Type or paste rows of problems, the first number then the second, for example two columns from a spreadsheet. Each row uses the operation chosen above (+).
| # | First | Second |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
Answers
| Problem | Binary | Decimal |
|---|---|---|
| 1011 + 110 | 10001 | 17 |
| 1111 + 1 | 10000 | 16 |
| 11001 + 111 | 100000 | 32 |
| 101 + 11 | 1000 | 8 |
How it's worked out
Binary is base 2. Each column holds a 0 or a 1, and each column is worth twice the one to its right: 1, 2, 4, 8, 16 and so on. You add binary numbers the same way you add decimal ones, column by column from the right. The only change is that a column overflows at 2 instead of 10.
| Column holds | Total | Write | Carry |
|---|---|---|---|
| 0 + 0 | 0 | 0 | 0 |
| 0 + 1 | 1 | 1 | 0 |
| 1 + 1 | 10 | 0 | 1 |
| 1 + 1 + carry | 11 | 1 | 1 |
Subtraction also runs right to left. When a column has 0 to take 1 from, it borrows from the next column to the left. That borrow is worth 2 in this column, so 0 − 1 becomes 2 − 1 = 1. If the next column is also 0, the borrow passes on until it reaches a 1.
Multiplication is shift and add. Each 1 in the bottom number copies the top number, moved left by that bit's place; each 0 adds nothing. Add the rows and you have the product. Division runs the other way: bring down one bit at a time, write 1 in the answer when the divisor fits and subtract it, or write 0 when it does not.
The column working draws each method as on paper, one step at a time. The last step checks the answer in decimal: it adds up the place values of the 1 bits and compares them with the same sum done in base 10.
Worked examples
Aisha adds 1011 and 110 for homework
Aisha lines the numbers up on the right, so 110 becomes 0110. Column by column from the right: 1 + 0 = 1, then 1 + 1 = 10, then 0 + 1 + 1 carried = 10, then 1 + 0 + 1 carried = 10. Each 10 means write 0 and carry 1. The last carry becomes a new left-hand digit, so the answer is 10001.
There were 3 carries. To check, 10001 is 16 + 1 = 17, and in decimal 11 + 6 = 17 too.
Ben subtracts 1 from 1000
Ben's right-hand column is 0 − 1, so he must borrow, but the next three columns are 0 as well. The borrow passes through each 0, which then gives 1 to its right, until it reaches the 1 at the left. That makes 3 borrows, and the answer is 111, which is 8 − 1 = 7.
A smaller case is 1010 − 11 = 111, or 10 − 3 = 7. If the second number is the larger, as in 11 − 101, subtract the smaller from the larger and put a minus sign in front: −10.
Chloe multiplies 111 by 111
All three bits of the bottom number are 1, so Chloe writes three rows: 111, 1110, 11100. Each is the top number moved one more place left.
Adding the rows gives 110001. That is 32 + 16 + 1 = 49, the same as 7 × 7 in decimal. A 0 bit in the bottom number gives a row of 0s, so 101 × 11 needs only the rows for its two 1 bits: 1111.
Reading your result
The answer is in binary, with decimal and hex beside it. Hex is base 16, where each digit stands for 4 bits. For division you also get the remainder: 1101 ÷ 100 is 11 with 1 left over, because 3 × 4 = 12 and 12 + 1 = 13.
A carry out of the top column makes the answer one bit longer. 1111 + 1 = 10000: the carry runs through every column. On paper you just write the extra digit.
Real hardware has a fixed width. An 8-bit register cannot hold 11111111 + 1 = 100000000. It keeps the low 8 bits, 00000000, and the lost carry is called overflow/02%3A_Binary_Arithmetic/2.05%3A_Binary_Overflow). The tool says which width holds your answer: 256 needs 16 bits as an unsigned number. It works to 256 digits, so even 64 ones plus 1 is exact, a 1 followed by 64 zeros.
Negative numbers are written with a minus sign here. Computers usually store them in two's complement/02%3A_Binary_Arithmetic/2.03%3A_Negative_Binary_Numbers) instead: flip every bit and add 1. Then subtracting is just adding the negative and dropping the extra carry bit.
Common mistakes
- Writing 2 in a column. 1 + 1 is 10 in binary, so you write 0 and carry 1. A 2 or a 3 never appears in a binary answer.
- Forgetting the carry when it meets 1 + 1. A column with 1 + 1 and a carry is 11: write 1 and carry 1 again.
- Borrowing only one column away. In 1000 − 1 the borrow must pass through every 0 until it reaches a 1, and each 0 it passes becomes 1.
- Not lining up on the right. 1011 + 110 means 1011 + 0110. Lining the numbers up on the left adds the wrong place values.
- Skipping a row for a 0 bit when multiplying. The rows still move left for each place, so a 0 in the middle of the bottom number shifts the next row two places.
Questions people ask
Sources
- Kuphaldt, Lessons in Electric Circuits, volume IV, 2.2 Binary Addition (LibreTexts)
- Kuphaldt, Lessons in Electric Circuits, volume IV, 2.3 Negative Binary Numbers (LibreTexts)
- Kuphaldt, Lessons in Electric Circuits, volume IV, 2.4 Binary Subtraction (LibreTexts)
- Kuphaldt, Lessons in Electric Circuits, volume IV, 2.5 Binary Overflow (LibreTexts)