Binary arithmetic: add, subtract, multiply and divide
The four operations work the same way in binary as in decimal, with only two digits to worry about. Here are the rules and a worked example of each; try your own numbers in the calculator.
Binary addition
Add column by column from the right and carry when a column reaches two.
| Sum | Write | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 | 1 | 1 |
Example: 10110 + 1101 = 100011, which is 22 + 13 = 35.
111 carries 10110 + 1101 ────── 100011
Binary subtraction
Subtract column by column from the right. 1 − 0 = 1, 1 − 1 = 0, 0 − 0 = 0. For 0 − 1, borrow from the next column to the left: the 0 becomes 10 (two) and 10 − 1 = 1.
Example: 11010 − 1011 = 1111, which is 26 − 11 = 15.
Computers subtract by adding the two’s complement instead. In 8 bits, −1011 is stored as 11110101; 00011010 + 11110101 = 1 00001111, and dropping the carry out of the top leaves 00001111, which is 15.
1111 borrowed from 11010 − 01011 ───── 01111
Binary multiplication
Multiplying by a binary digit is easy: × 1 copies the number and × 0 gives 0. So write one line for each digit of the bottom number, shifted one place left each time, and add the lines.
Example: 1101 × 101 = 1000001, which is 13 × 5 = 65.
1101
× 101
───────
1101
+ 00000
+ 110100
───────
1000001Binary division
Long division in binary only ever asks one question: does the divisor fit into what you have so far? If yes, write 1 and subtract; if no, write 0. Bring down the next bit and repeat.
Example: 11011 ÷ 11 (27 ÷ 3). The quotient is 1001, which is 9, with remainder 0.
| Bits brought down | Working value | Does 11 fit? | Quotient bit | Left over |
|---|---|---|---|---|
| 1 | 1 | no | 0 | 1 |
| 11 | 11 | yes, subtract 11 | 1 | 0 |
| 110 | 0 | no | 0 | 0 |
| 1101 | 1 | no | 0 | 1 |
| 11011 | 11 | yes, subtract 11 | 1 | 0 |
What happens when the answer doesn’t fit?
On paper a sum can always grow another digit. In a computer the number of bits is fixed, so a carry out of the top bit is lost. In 8 bits, 11111111 + 1 gives 00000000. The binary calculator shows this when you pick a bit width, with separate flags for unsigned and signed overflow.
For practice, the binary worksheets include addition sheets with answer keys.
How it’s calculated
Results use exact whole-number arithmetic at any size. With a bit width chosen, the result is wrapped to that width the way a CPU register does, and overflow is checked separately for unsigned and signed (two’s complement) readings.
Questions
What is 1 + 1 in binary?
10: write 0 and carry 1. It is the binary way of writing two.
What is 1 + 1 + 1 in binary?
11: write 1 and carry 1. It is three.
How do you subtract a bigger binary number from a smaller one?
Subtract the smaller from the bigger and put a minus sign in front, or, in a fixed number of bits, add the two’s complement and read the result as a signed number.
Is binary division exact?
Whole-number division gives a quotient and a remainder, as in decimal. 11011 ÷ 11 divides exactly; 11010 ÷ 11 leaves remainder 10, which is 2.