Saved

Press the star next to a tool's name to save it.

All my tools

Binary Calculator

Use this binary calculator to add, subtract, multiply and divide binary numbers, and to find a two's complement, with the result in binary and decimal.

Restored your last values ·

Type each number using only 0 and 1. Choose add, subtract, multiply or divide, and the result is shown in binary and in decimal. For a two's complement, enter one binary number and the width in bits: the calculator flips the bits and adds 1.

Everything is worked out in your browser. Nothing you type is sent anywhere.

–

–

Choose an operation, enter your binary numbers, then press Calculate.

A binary calculator adds, subtracts, multiplies and divides binary numbers, and finds the two's complement of a number. Type the numbers using 0 and 1, choose the operation and press the button. The answer is shown in binary and in decimal, with the decimal working so that you can check it. The method follows the Wikipedia pages on binary numbers and two's complement, and the work is done in your browser. It covers the binary operations, binary addition, binary subtraction and binary division calculators.

How to use the binary calculator

  1. Choose the operation: add, subtract, multiply, divide or two's complement.
  2. Type the first binary number and the second binary number, using only 0 and 1.
  3. For a two's complement, give the width in bits.
  4. Press Calculate.

How binary numbers work

The Wikipedia page explains that binary is a positional system with base 2. Each digit, or bit, is worth a power of 2, starting with 2 to the power 0 at the right. So 100101 is 32 + 4 + 1, which is 37 in decimal. The calculator shows both forms for the result, so you can convert in your head or check the answer.

Binary addition

Binary addition follows the same column method as decimal addition, but a column that adds up to 2 gives 0 and carries 1. The rules are 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1) and 1 + 1 + 1 = 11 (write 1, carry 1). For 101 plus 11, the numbers are 5 and 3, and the sum is 1000, which is 8.

Binary subtraction

Subtraction works column by column with borrowing. A 0 minus a 1 borrows from the next column, which turns the 0 into 10, which is 2. If the second number is larger, the result is negative, and the calculator shows it with a minus sign: 11 minus 101 is −10, which is −2 in decimal. Computers do this with two's complement, which is described below.

Binary multiplication and division

Binary multiplication is easy because each digit of the second number is either 0 or 1: you shift the first number to the left for each bit and add the copies where the bit is 1. For 1101 times 101, which is 13 times 5, the result is 1000001, or 65. Binary division works like long division. 1101 divided by 101 is 13 divided by 5, giving a quotient of 10 (2) and a remainder of 11 (3). The calculator gives the quotient and the remainder in binary, and the check in decimal.

Two's complement

Two's complement is the way computers store negative numbers. The page gives the procedure: write the number in binary, invert all the bits, and add 1, ignoring any overflow. For 6 in 4 bits, 0110 becomes 1001, and adding 1 gives 1010, which stands for −6. For 5 in 8 bits, 00000101 becomes 11111010, and adding 1 gives 11111011, which is −5. In n bits, the range is from −2 to the power n − 1 up to 2 to the power n − 1, minus 1. Enter a number and a width to see each step.

Checking your work

A good habit is to convert both numbers to decimal, do the sum there, and compare. The calculator prints this check, for example 5 + 3 = 8, so a mistake in typing a digit shows up at once. For long numbers, the check also confirms that the carries were handled correctly.

A worked example of each operation

Take 1011 and 110, which are 11 and 6 in decimal. Adding gives 10001, which is 17. Subtracting 110 from 1011 gives 101, which is 5. Multiplying gives 1000010, which is 66, since 11 times 6 is 66. Dividing 1011 by 110 gives a quotient of 1 and a remainder of 101, which is 11 divided by 6, equal to 1 remainder 5. You can enter these pairs in the calculator and compare each line with the decimal check that it prints.

Why computers use binary

Digital circuits have two stable states, on and off, which map neatly to the digits 1 and 0. All data in a computer, from numbers to text to images, is stored as groups of bits. A group of eight bits is a byte, and it can hold 256 different values, from 0 to 255 when read as an unsigned number, or from −128 to 127 in two's complement. Working in binary by hand helps in understanding how overflow, masking and shifting behave inside a processor.

Converting between binary and decimal

To convert a binary number to decimal, add the powers of 2 for each 1 bit, or use the doubling method: start at 0, and for each bit from the left, double the total and add the bit. For 100101011012 the doubling steps run 1, 2, 4, 9, 18, 37, 74, 149, 299, 598, 1197, so it is 1,197 in decimal. To convert the other way, divide by 2 again and again and read the remainders from the last to the first. The binary to decimal converter on this site does this for you, while this calculator works in binary and shows the decimal equivalent as a check.

Carries in long additions

When you add long binary numbers, the carry can ripple across many columns, as in 1111 plus 1, which gives 10000. Each column handles three inputs, the two bits and the carry, and the result of a column is 0 to 3 in decimal, which is 0 to 11 in binary. Keeping this in mind makes hand addition of long numbers reliable.

Common mistakes

  • Typing a digit other than 0 or 1. A binary number has only two digits.
  • Forgetting the carry. 1 + 1 is 10, not 2.
  • Dropping the width in two's complement. The same bits mean different values in other widths.
  • Expecting decimals from division. This tool gives a quotient and a remainder.
  • Reading the sign wrongly. A leading 1 in two's complement means negative.

What next

Use this often? Add Binary to your Home screen.

Frequently asked questions

What is a binary calculator?

A tool that does arithmetic on numbers written with only 0 and 1, and gives the answer in binary and decimal.

How do you add binary numbers?

Add column by column: 1 + 1 = 10, so write 0 and carry 1. 101 + 11 = 1000, which is 5 + 3 = 8.

How do you subtract binary numbers?

Subtract column by column and borrow when a 0 meets a 1. 11 − 101 = −10, which is 3 − 5 = −2.

How do you divide binary numbers?

Use long division. 1101 ÷ 101 gives quotient 10 and remainder 11, which is 13 ÷ 5 = 2 remainder 3.

How do you find the two's complement?

Flip all the bits and add 1. In 4 bits, 0110 becomes 1001, then 1010, which is −6.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Developer Tools