Add, subtract, multiply or divide two binary numbers, or convert a number between binary and decimal.
Enter two binary numbers, made of 0s and 1s only, and pick an operation.
Convert a binary number to a decimal number.
Convert a whole decimal number to binary.
| Decimal | Binary | Decimal | Binary |
|---|---|---|---|
| 0 | 0 | 8 | 1000 |
| 1 | 1 | 10 | 1010 |
| 2 | 10 | 16 | 10000 |
| 3 | 11 | 20 | 10100 |
| 4 | 100 | 64 | 1000000 |
| 7 | 111 | 255 | 11111111 |
The binary system counts in base 2. Where decimal uses ten digits, 0 to 9, and each place is worth ten times the one to its right, binary uses only 0 and 1 and each place is worth twice the one to its right. The binary number 1011 is 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1, which is 11 in decimal. Computers use binary because circuits that detect only two states, on and off, are easy to build and reliable.
The page opens with two binary numbers, 10101010 and 11001100, which are 170 and 204 in decimal. Added together they give 101110110 in binary, which is 374 in decimal (170 + 204). Subtracting gives -100010 (-34), multiplying gives 1000011101111000 (34,680), and dividing gives a quotient of 0 and a remainder of 10101010, in decimal 0 remainder 170.
| Operation | Binary result | Decimal check |
|---|---|---|
| 10101010 + 11001100 | 101110110 | 170 + 204 = 374 |
| 10101010 − 11001100 | -100010 | 170 − 204 = -34 |
| 10101010 × 11001100 | 1000011101111000 | 170 × 204 = 34,680 |
| 10101010 ÷ 11001100 | 0 remainder 10101010 | 170 ÷ 204 = 0 remainder 170 |
Because 170 is smaller than 204, the default division gives a quotient of 0 with the whole of 170 left as the remainder. Swap the numbers and 11001100 ÷ 10101010 gives a quotient of 1 and a remainder of 100010, which is 204 ÷ 170 = 1 remainder 34 in decimal, because 204 = 170 × 1 + 34. You can always check a division by multiplying the quotient by the divisor and adding the remainder.
Electronic circuits are most reliable when they only have to tell two states apart, such as a high and a low voltage. Every number, letter, picture and sound in a computer is stored as patterns of those two states. Larger values are built by grouping bits: 8 bits make a byte, and common word sizes are 16, 32 and 64 bits.
To convert binary to decimal, add up the place value of every 1. Counting from 0 at the right, the place values are 1, 2, 4, 8, 16, 32, 64, 128 and so on. For 10101010 the 1s are in places worth 128, 32, 8 and 2, so the value is 170.
| Place (power of 2) | Place value | Bit in 10101010 | Contribution |
|---|---|---|---|
| 27 | 128 | 1 | 128 |
| 26 | 64 | 0 | 0 |
| 25 | 32 | 1 | 32 |
| 24 | 16 | 0 | 0 |
| 23 | 8 | 1 | 8 |
| 22 | 4 | 0 | 0 |
| 21 | 2 | 1 | 2 |
| 20 | 1 | 0 | 0 |
Divide the number by 2 again and again and write down the remainders, then read them from last to first. For 170:
| Divide | Quotient | Remainder |
|---|---|---|
| 170 ÷ 2 | 85 | 0 |
| 85 ÷ 2 | 42 | 1 |
| 42 ÷ 2 | 21 | 0 |
| 21 ÷ 2 | 10 | 1 |
| 10 ÷ 2 | 5 | 0 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders from the bottom to the top gives 10101010.
Addition, subtraction, multiplication and division follow the same rules as in decimal, except you carry or borrow when a column reaches 2 instead of 10. In addition, 1 + 1 is 10 (write 0, carry 1), and 1 + 1 + 1 is 11. The calculator does the sums exactly, for numbers of any length, using arbitrary-precision integers, and shows the matching decimal calculation so you can check the answer. Division gives a whole-number quotient and a remainder. Division by zero is not possible and shows a message.
A single binary digit is a bit and eight bits make a byte, which can hold 0 to 255. Some common values written in binary, padded to a byte:
| Decimal | Binary (8 bits) |
|---|---|
| 1 | 00000001 |
| 5 | 00000101 |
| 10 | 00001010 |
| 65 | 01000001 |
| 127 | 01111111 |
| 170 | 10101010 |
| 255 | 11111111 |
| Power of 2 | Value |
|---|---|
| 20 | 1 |
| 21 | 2 |
| 22 | 4 |
| 23 | 8 |
| 24 | 16 |
| 25 | 32 |
| 26 | 64 |
| 27 | 128 |
| 28 | 256 |
| 210 | 1,024 |
| 216 | 65,536 |
| 232 | 4,294,967,296 |
The large line is the binary result. Below it are the two operands in binary and the same sum in decimal, so you can check the answer. The other two tools convert one number at a time: binary to decimal, and decimal to binary. For base 16 use the Hex Calculator, and for very large decimal numbers use the Big Number Calculator.
Add the bits column by column from the right. 0 + 0 is 0, 0 + 1 is 1, and 1 + 1 is 10, so write 0 and carry 1 to the next column.
Multiply each bit by 2 raised to its position, counting from 0 at the right, and add the results. For 1011 that is 8 + 0 + 2 + 1, which is 11.
Divide the number by 2 repeatedly and keep the remainders. Reading the remainders from the last to the first gives the binary number. For example, 11 gives 1011.
The calculator gives a whole-number quotient and a remainder, both in binary and decimal. Division by zero is not possible.
You can use a minus sign for a negative whole number. Fractional binary numbers, with a binary point, are not supported.
There is no fixed limit. The calculator uses arbitrary-precision integers, so very long binary numbers are handled exactly.
Sources: CS50: Lecture 0, binary and computers; MDN: BigInt (arbitrary-precision integers)
Pick another tool to jump straight to it.