Binary Calculator
Do arithmetic on two binary numbers and see the answer in three bases.
How it works
Binary arithmetic follows the same rules as ordinary arithmetic, with only two digits to remember.
Addition. 0 + 0 is 0. 0 + 1 is 1. 1 + 1 is 10, so you write 0 and carry 1. 1 + 1 + 1 is 11, so you write 1 and carry 1. Work from the right, column by column, as you would in decimal.
Subtraction. When you need to take 1 from 0, borrow from the next column. The borrowed 1 is worth 2 in the column you are working on.
Multiplication. Each line is either a copy of the top number or a row of zeros, shifted one place left each time. Add the lines.
AND, OR and XOR compare the two numbers bit by bit. AND gives 1 only where both have a 1. OR gives 1 where either has a 1. XOR gives 1 where exactly one has a 1.
Division here is whole number division, with the remainder shown separately.
Worked example
1011 + 110: from the right, 1 + 0 = 1. 1 + 1 = 10, write 0 carry 1. 0 + 1 + 1 = 10, write 0 carry 1. 1 + 1 = 10. Answer: 10001, which is 11 + 6 = 17.
Powers of 2
| Position from right | Power | Value |
|---|---|---|
| 0 | 20 | 1 |
| 1 | 21 | 2 |
| 2 | 22 | 4 |
| 3 | 23 | 8 |
| 4 | 24 | 16 |
| 5 | 25 | 32 |
| 6 | 26 | 64 |
| 7 | 27 | 128 |
| 8 | 28 | 256 |
| 9 | 29 | 512 |
| 10 | 210 | 1,024 |
| 11 | 211 | 2,048 |
| 12 | 212 | 4,096 |
| 13 | 213 | 8,192 |
| 14 | 214 | 16,384 |
| 15 | 215 | 32,768 |
| 16 | 216 | 65,536 |
Common questions
What is 1 + 1 in binary?
10. It means one two and no ones.
How are negative results shown?
With a minus sign in front. Computers usually store negatives in two's complement form, which depends on a fixed number of bits.