Converting binary to decimal means turning a base-2 number into the base-10 number system people use every day, and it works entirely through place values, no ASCII table needed.
This is a different kind of conversion from turning binary into letters: here the binary number represents a quantity, not a character, so the math works differently under the hood.
The Place-Value Method
In an 8-bit binary number, each position stands for a power of two: 128, 64, 32, 16, 8, 4, 2, and 1, reading left to right. A decimal value only counts a position if that digit is a 1.
Step by Step
Write the power-of-two value above every digit in the binary number. Add together only the values sitting above a 1. Ignore every position where the digit is a 0. The total is the decimal number.
A Worked Example
Take 01011010. The 1s sit in the 64, 16, 8, and 2 positions. Adding 64 plus 16 plus 8 plus 2 gives 90, so 01011010 equals 90 in decimal.
Going the Other Direction
Converting decimal back to binary works in reverse: subtract the largest power of two that fits, mark that position as 1, and repeat with what is left until nothing remains.
Powers of Two Worth Memorizing
20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = 16, 25 = 32, 26 = 64, 27 = 128, 28 = 256, 29 = 512, 210 = 1024. If you know these, you can convert most numbers in your head. Notice that each value is double the one before it.
Decimal to Binary: The Division Method
Another way to convert a decimal number is to divide it by 2 repeatedly and note the remainders. Take 45: 45 divided by 2 is 22 remainder 1, 22 divided by 2 is 11 remainder 0, 11 divided by 2 is 5 remainder 1, 5 divided by 2 is 2 remainder 1, 2 divided by 2 is 1 remainder 0, and 1 divided by 2 is 0 remainder 1. Read the remainders from bottom to top and you get 101101, which is 00101101 as a full byte. Check it: 32 + 8 + 4 + 1 = 45.
Handy Shortcuts
- Odd or even: if the last digit is 1, the number is odd. If it is 0, the number is even.
- All ones: a number made only of 1s equals a power of two minus one. For example, 1111 is 15 and 11111111 is 255.
- One followed by zeros: a single 1 followed by zeros is a power of two. For example, 10000 is 16 and 10000000 is 128.
- Leading zeros: zeros on the left change nothing, so 00101101 and 101101 are both 45.
How Many Bits Do You Need?
With n bits you can write numbers from 0 to 2n minus 1. Four bits cover 0 to 15, eight bits cover 0 to 255, and sixteen bits cover 0 to 65,535. This is why a single byte can hold a number up to 255, and why colors in web design use values from 0 to 255 for red, green and blue.
Practice Questions
Convert these binary numbers to decimal, then check the answers below.
00001010001010100110010011001000
Answers: 1) 10, 2) 42, 3) 100, 4) 200.
Negative Numbers
The method above covers positive whole numbers. Computers store negative numbers with a system called two’s complement, where the leftmost bit signals the sign. That is a topic of its own, but it explains why the same 8 bits can mean 200 in one program and a negative number in another.
Practice More
For more worked examples at different bit lengths, see our binary to decimal practice guide and our breakdown of common binary number conversions like 256 and 128. For the full picture of how the number system works, start with what binary code is and how it works.
