StringMash.com

Binary calculator

Binary sums worked the way you'd do them on paper, with the answer in decimal and hex too.

10 characters
Updates as you type
Binary1 0001
Hex11
Decimal17

Show the steps
  1. Add column by column from the right. When a column reaches 2, write what's left and carry 1.
  2. carries 1 1 1
  3. 1 0 1 1
  4. + 1 1 0
  5. ---------
  6. 1 0 0 0 1

Using the calculator

Type a binary sum: `1011 + 110`, `1011 - 110`, `101 * 11` or `1100 / 11`. The answer appears in binary, hex and decimal, and Show the steps does it the paper way, with the carries, borrows and partial products written out.

Spaces and the _ character inside a number are ignored, so `1010_1010` is fine. The same box does `AND`, `OR`, `XOR`, `NOT` and shifts, which line the bits up in the working.

Binary addition

There are only four facts to know. 0 + 0 is 0, 0 + 1 is 1, 1 + 1 is 10 (write 0, carry 1), and 1 + 1 + 1 is 11 (write 1, carry 1). Add from the right, column by column, and carry into the next column whenever a column reaches 2.

`1011 + 110` is 11 + 6 in decimal. From the right: 1 + 0 is 1; 1 + 1 is 10, carry 1; 0 + 1 + 1 is 10, carry 1; 1 + 0 + 1 is 10, carry 1; and the last carry comes down. That gives 10001, which is 17.

Subtraction and multiplication

Subtraction borrows 2 from the next column when it needs to take 1 from 0. The working marks every borrow. If the second number is the bigger one, the answer is negative.

Binary multiplication is the easiest kind of long multiplication there is. Each digit of the bottom number is 0 or 1, so each row is either nothing or a copy of the top number shifted left. Add the copies and you're done: `101 × 11` is 101 plus 1010, which is 1111. A computer's multiplier does the same thing in hardware.

The kitchen table

In November 1937 George Stibitz, a researcher at Bell Labs, finished a binary adder built from telephone relays at home. He later called it the Model K, after the kitchen table it was said to have been put together on. The rules it wired into relays are the four in the section above, and every adder in every processor since follows them.

Questions

What is 1 + 1 in binary?

10. Write 0 and carry 1, the same way 9 + 1 carries in decimal.

How do you subtract in binary?

Column by column from the right. When the top bit is 0 and you need to take away 1, borrow 2 from the next column.

Can I mix binary and decimal?

Yes. Prefix a number with 0d for decimal or 0x for hex, like 1010 + 0d5.

Why does the binary answer have spaces?

It's grouped in fours, so it's easy to read and each group matches one hex digit. Copy it and paste it anywhere; the calculator itself ignores the spaces.

Sources

Added . What's new