How to Convert Binary to Decimal
Binary is base 2, so each place is worth twice the one to its right instead of ten times. Converting to decimal means adding up the places where a 1 appears, and it is easier than the notation suggests once you know the place values.
The place values
From the right, the places are 1, 2, 4, 8, 16, 32, 64, 128. A byte is eight bits, so its largest value is the sum of all eight, which is 255.
Every value in that range has exactly one binary representation, which is why binary is unambiguous.
Convert between binary, decimal, octal and hex.
Open the Binary to Decimal Converter →A worked example
Convert 1011. Write the places over the digits: 8, 4, 2, 1. The digits are 1, 0, 1, 1, so add 8 + 2 + 1 = 11.
Convert 110101: places 32, 16, 8, 4, 2, 1 give 32 + 16 + 4 + 1 = 53. Adding only the places with a 1 is the whole method.
The doubling shortcut
To read a binary number left to right, start with the first digit and double, adding the next digit each time. For 1011: start 1, double to 2 and add 0 gives 2, double to 4 and add 1 gives 5, double to 10 and add 1 gives 11.
This works because each step shifts the existing value one place to the left, which is a doubling in base 2. It is faster than writing out place values for long numbers.
Converting decimal to binary
Repeatedly divide by 2 and record the remainders, then read them from the bottom up. For 53: 53/2 = 26 remainder 1; 26/2 = 13 remainder 0; 13/2 = 6 remainder 1; 6/2 = 3 remainder 0; 3/2 = 1 remainder 1; 1/2 = 0 remainder 1.
Reading the remainders upward gives 110101, which matches the earlier example. The other method is to subtract the largest power of two that fits, repeatedly.
A table of small values
| Decimal | Binary | Decimal | Binary |
|---|---|---|---|
| 0 | 0 | 8 | 1000 |
| 1 | 1 | 9 | 1001 |
| 2 | 10 | 10 | 1010 |
| 3 | 11 | 11 | 1011 |
| 4 | 100 | 12 | 1100 |
| 5 | 101 | 13 | 1101 |
| 6 | 110 | 14 | 1110 |
| 7 | 111 | 15 | 1111 |
The first sixteen values are worth knowing by sight, because they cover the most common bit patterns in debugging.
Bits, bytes and prefixes
Eight bits make a byte, which holds 0 to 255. A nibble is four bits, holding 0 to 15, which maps exactly onto one hexadecimal digit.
That mapping is why hex is used to display binary compactly: each hex digit is four bits, so a byte is always two hex characters.
Signed numbers
Negative numbers in binary are usually stored in twos complement form: invert the bits and add one. The byte 11111111 is −1, and 10000000 is −128.
This is why a signed byte runs from −128 to 127 rather than 0 to 255. Reading binary output without knowing whether it is signed is a common source of confusion.
Common mistakes
- Starting the place values at 2 instead of 1.
- Reading the digits left to right as if they were decimal.
- Forgetting that leading zeros do not change the value.
- Mixing up 1000 (eight) with 100 (four).
- Assuming a byte is unsigned.
Where this shows up
File permissions, subnet masks, bit flags and hardware registers are all binary in disguise. Reading a permission mask such as 755 in octal, or a subnet mask in dotted decimal, depends on the same place-value idea.
Once the conversion is quick, those notations stop looking arbitrary and become readable.
A check on the answer
The result must be smaller than the next power of two above the number of bits. Four bits cannot exceed 15, and eight cannot exceed 255.
If the answer is larger, a place value has been counted twice or the digits were misaligned.
Reading a byte quickly
Split the byte into two nibbles and read each as a hex digit. That is faster than adding eight place values and it matches how the value is usually displayed.
11010110 becomes D6, which is 214 in decimal.
Frequently asked questions
What is 11111111 in decimal?
255, the largest value in one unsigned byte.
How do I convert binary to hex?
Group the bits into fours from the right and convert each group to a hex digit.
Why do computers use binary?
Because two stable states are easy to represent reliably in electronic circuits.