How this calculator works
Three tools sit behind the tabs. The first takes two binary values and applies one of the four arithmetic operations. The second reads a binary value and gives its decimal equivalent. The third goes the other way, from decimal back to binary.
Every answer is shown in both bases at once, because the decimal line is the quickest way to check that the binary line is right. Underneath, the working is laid out the way it would be on paper — place values for a conversion, carries and borrows for arithmetic, division steps for the decimal-to-binary direction.
place 128 64 32 16 8 4 2 1
value 128 + 32 + 8 + 2 = 170
Why computers count in twos
A decimal digit needs ten distinguishable states. A binary digit needs two, and two states are easy to build reliably: a voltage that is high or low, a switch that is open or closed, a region of disc magnetised one way or the other. Noise has to be enormous before high is mistaken for low, which is why every general-purpose computer ever built settled on base 2.
The cost is length. The number 170 takes three digits in decimal and eight in binary, and that ratio holds roughly: binary strings run about 3.3 times longer than their decimal equivalents. For a machine that is a fair trade, since a long string of reliable digits beats a short string of unreliable ones.
Reading a binary number
Place values double from the right instead of multiplying by ten. The rightmost digit is worth 1, the next 2, then 4, 8, 16 and onward. A digit is either present or absent, so there is no multiplication to do — add up the place values that carry a 1 and you have the number.
| Binary | Place values used | Decimal |
|---|---|---|
| 1 | 1 | 1 |
| 101 | 4 + 1 | 5 |
| 1111 | 8 + 4 + 2 + 1 | 15 |
| 10000 | 16 | 16 |
| 10101010 | 128 + 32 + 8 + 2 | 170 |
| 11111111 | 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 | 255 |
Two patterns are worth committing to memory. A 1 followed by n zeros is 2 raised to the power n, so 10000 is 16. And a string of n ones is one less than the next power of two, which is why 11111111 is 255 rather than 256 and why so many limits in computing land one short of a round number.
Addition and subtraction, column by column
Binary addition is decimal addition with a smaller alphabet. Work right to left; whenever a column reaches two, write 0 and carry 1. There are only four cases to learn:
0 + 1 = 1 1 + 1 = 0, carry 1
Carrying happens far more often than in decimal, because the column fills at two rather than ten. Adding 1111 and 1 cascades a carry through every column and lands on 10000:
+ 1
------
10000
Subtraction works the same way with borrowing instead of carrying: 0 minus 1 needs a borrow from the column to the left, which is worth 2 rather than 10. Where the second number is larger, this page subtracts the smaller from the larger and marks the answer negative, which is what a person doing it on paper would do. Computers handle negatives differently, usually with two's complement, where the leading bit carries the sign.
Multiplication and division
Binary multiplication is unusually easy, because every digit of the multiplier is either 0 or 1. There is no times table: each row of the working is either a copy of the first number, shifted, or a row of zeros. Add the rows and you are finished.
× 110 (6)
--------
0000
1010
1010
--------
111100 (60)
Division follows the long-division shape, asking at each step whether the divisor fits into the current remainder. In binary the answer to that question is only ever yes or no, which makes each step a single comparison. The result is given as a whole number with a remainder, since that is what integer division produces; for a decimal answer, convert first and divide in base 10.
Converting both ways by hand
Binary to decimal is the place-value sum already described: add the values of the columns holding a 1.
Decimal to binary runs the other way, by repeated halving. Divide by 2, write down the remainder, and repeat with the quotient until nothing is left. The remainders read from bottom to top are the binary digits:
85 ÷ 2 = 42 r 1
42 ÷ 2 = 21 r 0
21 ÷ 2 = 10 r 1
10 ÷ 2 = 5 r 0
5 ÷ 2 = 2 r 1
2 ÷ 2 = 1 r 0
1 ÷ 2 = 0 r 1
read upward → 10101010
Reading the remainders in the wrong direction is the classic error here, and it produces a number that looks plausible but is wrong. The conversion tab prints the steps in order so the direction is never in doubt.
Where binary shows up
- Network masks. A subnet mask such as 255.255.255.0 is four groups of eight bits, and the split between network and host only makes sense in binary. Our IP subnet calculator works through that.
- File permissions. The Unix mode 755 is three groups of three bits, each one standing for read, write and execute.
- Colour values. A hex colour is three bytes, and each byte is eight bits running from 0 to 255.
- Flags and bitmasks. Packing many on-or-off settings into one number is still the compact way to store them.
- Character encoding. Every letter on this page is a pattern of bits before it is anything else.
Edge cases and common mistakes
- Reading 10 as ten. In binary it is two. The safest habit is to read digits individually: "one zero", not "ten".
- Leading zeros. 0101 and 101 are the same number. They change nothing mathematically, though fixed-width contexts such as a byte often write them for alignment.
- Mixing bases without saying so. 1010 is ten in binary and one thousand and ten in decimal. Label which base you are in whenever both are on the page.
- Expecting a fractional answer from division. This page gives a quotient and a remainder, not a binary fraction.
- Entering a digit other than 0 or 1. There is no 2 in binary, so the page asks for a correction rather than guessing what you meant.
What this page does not do
It works on whole numbers. Binary fractions such as 1010.11 are not accepted, and a decimal fraction has its fractional part dropped before conversion. It does not perform bitwise operations such as AND, OR, XOR or shifts, and it does not show two's complement representations of negative values. For base 16, our hex calculator covers the same ground, and the big number calculator handles decimal arithmetic at any length.
Everything is computed on your own device in exact integer arithmetic, so there is no bit-width limit and nothing you enter is sent anywhere.
Frequently asked questions
How do I add two binary numbers?
Column by column from the right, exactly as in decimal, except that carrying starts at 2 instead of 10. Zero plus zero is 0, one plus zero is 1, and one plus one is 0 with a 1 carried to the next column. Enter both values above and the carry row appears underneath.
How do I convert binary to decimal by hand?
Give each digit a place value doubling from the right — 1, 2, 4, 8, 16 and so on — then add the place values wherever the digit is 1. For 10101010 that is 128 + 32 + 8 + 2, which is 170.
How do I convert decimal to binary by hand?
Divide by 2 repeatedly and keep the remainders. Reading those remainders from the last one back to the first gives the binary digits. The conversion tab shows every division step for the number you enter.
Why does 1 + 1 equal 10 in binary?
Because binary has only two digits. Counting goes 0, 1, and then the column is full, so it rolls over to 10 the same way decimal rolls from 9 to 10. The symbol 10 here means two, not ten.
What happens to the fractional part of a decimal number?
It is dropped. Entering 10.75 converts the whole-number part and returns 1010, which is what the standard references do too. The page tells you when it has ignored a fraction rather than letting you assume it was included.
Can this handle negative numbers?
Subtraction can produce a negative answer and it is shown with a minus sign. The conversion tabs also accept a negative decimal. The arithmetic tab itself takes positive binary values only, since a leading minus is not a binary digit.
How large a binary number can I enter?
There is no fixed limit. Values are handled in exact whole-number arithmetic rather than being squeezed into a fixed number of bits, so a 200-digit binary string converts exactly, with no overflow and nothing rounded.
This calculator is provided for general technical and educational use. Results are computed in exact integer arithmetic and checked against an independent reference implementation, but any value you rely on in production code or network configuration deserves a second check. See our about page for how these tools are built and tested, and our privacy policy for what we do and do not collect.