Binary Calculator

Add, subtract, multiply or divide two binary numbers, or convert a number between binary and decimal.

Binary Calculation

Enter two binary numbers, made of 0s and 1s only, and pick an operation.

Binary to Decimal

Convert a binary number to a decimal number.

Decimal to Binary

Convert a whole decimal number to binary.

Common binary and decimal values

DecimalBinaryDecimalBinary
0081000
11101010
2101610000
3112010100
4100641000000
711125511111111
Quick answer. Binary is base 2, using only 0 and 1. 10101010 in binary is 170 in decimal, and 10101010 + 11001100 = 101110110 (170 + 204 = 374). To convert, add the place values of the 1 bits.

How binary works

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.

Worked example with the default numbers

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.

OperationBinary resultDecimal check
10101010 + 11001100101110110170 + 204 = 374
10101010 − 11001100-100010170 − 204 = -34
10101010 × 110011001000011101111000170 × 204 = 34,680
10101010 ÷ 110011000 remainder 10101010170 ÷ 204 = 0 remainder 170

Dividing the other way round

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.

Why computers use binary

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.

Converting binary to decimal

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 values of the default number 10101010 (the 1 bits are the ones that count)Add the place values of the 1 bits: 128 + 32 + 8 + 2 = 170.Place values of the default number 10101010 (the 1 bits are the ones that count)2^7 = 1281282^6 = 6402^5 = 32322^4 = 1602^3 = 882^2 = 402^1 = 222^0 = 10
Only the places holding a 1 contribute to the total.
Place (power of 2)Place valueBit in 10101010Contribution
271281128
266400
2532132
241600
23818
22400
21212
20100

Converting decimal to binary

Divide the number by 2 again and again and write down the remainders, then read them from last to first. For 170:

DivideQuotientRemainder
170 ÷ 2850
85 ÷ 2421
42 ÷ 2210
21 ÷ 2101
10 ÷ 250
5 ÷ 221
2 ÷ 210
1 ÷ 201

Reading the remainders from the bottom to the top gives 10101010.

Binary arithmetic

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.

How many values n bits can hold (2 to the power n)Each extra bit doubles the number of values: 8 bits hold 256 values (0 to 255) and 12 bits hold 4,096.How many values n bits can hold (2 to the power n)1 bits22 bits44 bits168 bits25610 bits1,02412 bits4,096
Every extra bit doubles what a binary number can represent.

Bits, bytes and common values

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:

DecimalBinary (8 bits)
100000001
500000101
1000001010
6501000001
12701111111
17010101010
25511111111
Power of 2Value
201
212
224
238
2416
2532
2664
27128
28256
2101,024
21665,536
2324,294,967,296
Digits needed: the same number in binary, decimal and hexadecimalBinary is long: 170 needs 8 binary digits, 3 decimal digits and 2 hexadecimal digits.Digits needed: the same number in binary, decimal and hexadecimalBinary (170)8Decimal (170)3Hexadecimal (AA)2
Hexadecimal (see the Hex Calculator) is a shorter way to write the same binary data.

What this calculator does not do

  • Negative numbers are shown with a minus sign, not in the two’s complement form computer hardware uses.
  • Only whole numbers are supported. Fractions with a binary point and floating-point values are stored differently and are not covered.
  • It does not apply a fixed word size, so there is no overflow: results can be any length.
  • Remainders take the sign of the first number, as with integer division in many programming languages.

Common mistakes

  • Typing a digit other than 0 or 1, which is rejected.
  • Reading binary digits from the wrong end. The rightmost digit is the 1s place.
  • Forgetting to carry when adding 1 + 1.
  • Confusing a decimal number such as 170 with a binary number when entering it in the binary box.

How to read your result

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.

The results are exact for whole numbers. For hardware or exam questions that use a fixed number of bits, check how negative numbers and overflow are handled.

What to do next

Common questions

How do you add binary numbers?

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.

How do you convert binary to decimal?

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.

How do you convert decimal to binary?

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.

What happens when I divide binary numbers?

The calculator gives a whole-number quotient and a remainder, both in binary and decimal. Division by zero is not possible.

Can I enter negative or fractional binary numbers?

You can use a minus sign for a negative whole number. Fractional binary numbers, with a binary point, are not supported.

How long can the numbers be?

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)

More Math Calculators

Pick another tool to jump straight to it.