How to Convert Binary to Decimal (and Back)
Computers think in binary — just two digits, 0 and 1 — while we count in decimal with ten digits, 0 to 9. Converting between them is a useful skill for students, programmers and anyone curious about how computers represent numbers. The method is straightforward once you see the pattern.
How binary works
In decimal, each position is a power of 10 (ones, tens, hundreds). In binary, each position is a power of 2 (1, 2, 4, 8, 16, …). A binary digit (bit) is either 0 or 1, telling you whether to include that power of two.
Binary to decimal
Write the powers of 2 above each bit from right to left, then add up the powers where the bit is 1. Take 1011: the positions are 8, 4, 2, 1. The bits are 1, 0, 1, 1 — so 8 + 0 + 2 + 1 = 11. So binary 1011 equals decimal 11.
Decimal to binary
Repeatedly divide the number by 2 and note the remainders. For 13: 13÷2 = 6 r1, 6÷2 = 3 r0, 3÷2 = 1 r1, 1÷2 = 0 r1. Read the remainders bottom to top: 1101. So decimal 13 is binary 1101.
- Each bit position is a power of two: 1, 2, 4, 8, 16, 32…
- Add the positions with a 1 to get the decimal value.
- Divide-by-2 with remainders converts decimal back to binary.
Why computers use binary
Computers are built from billions of tiny switches that are either on or off — there is no convenient 'half-on' state. Binary maps perfectly onto this reality: a 1 is on, a 0 is off. Representing numbers, text, images and sound as patterns of these two states is what lets a machine made of simple switches do extraordinarily complex work. Every photo, song and message on your device is, underneath, just a very long binary number.
Quick reference: 0 to 15 in binary
Four bits cover the numbers 0 through 15, which is handy to recognise on sight:
- 0 = 0000, 1 = 0001, 2 = 0010, 3 = 0011
- 4 = 0100, 5 = 0101, 6 = 0110, 7 = 0111
- 8 = 1000, 9 = 1001, 10 = 1010, 11 = 1011
- 12 = 1100, 13 = 1101, 14 = 1110, 15 = 1111
Why programmers group bits in fours: hexadecimal
Long binary numbers are painful to read and easy to mistype. Notice that four bits cover exactly 0 to 15 — sixteen values — which is precisely one hexadecimal digit. That is not a coincidence; it is the entire reason hex exists. Split any binary number into groups of four from the right and each group becomes a single hex character, using 0–9 then A–F for 10–15.
So 11010110 splits into 1101 and 0110, which are 13 and 6, giving hex D6 — and D6 is far easier to say, write and check than eight ones and zeros. Two hex digits describe exactly one byte, which is why byte values run 00 to FF, or 0 to 255 in decimal. Web colours use the same trick: #FF7F00 is three bytes meaning red 255, green 127, blue 0 — a strong orange. Once you see hex as shorthand for binary rather than as a separate system, it stops being intimidating.
Where you actually meet binary
This is not just classroom arithmetic. Binary shows up constantly the moment you touch a server or a network, usually disguised as ordinary-looking numbers:
- File permissions: chmod 755 is three sets of three bits. 7 is 111, meaning read, write and execute; 5 is 101, meaning read and execute but not write. So 755 is 'owner can do everything, everyone else can read and run'.
- Subnet masks: 255.255.255.0 is 11111111.11111111.11111111.00000000 — twenty-four ones followed by eight zeros, which is exactly why it is written as /24.
- Feature flags and bitmasks: a single integer can carry a dozen on/off settings, each occupying one bit, which is why you sometimes see options combined by adding numbers like 1, 2, 4 and 8.
- Character encoding: every letter you type is stored as a number, and looking at its binary form is how encoding problems get diagnosed.
- Data sizes: a kilobyte is 1,024 bytes rather than 1,000 because 1,024 is 2 to the power of 10 — the nearest round number in a base-2 world.
Two shortcuts worth memorising
First, the powers of two double each time: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024. Knowing these ten by heart makes most conversions instant. Second, an n-bit number holds 2^n different values, running from 0 up to 2^n − 1. Eight bits gives 256 values, 0 through 255 — which explains why so many limits in computing are 255, 65535 or 4,294,967,295. When you meet an odd-looking maximum in software, it is almost always a power of two minus one.
The bottom line
Binary is just base-2 counting with powers of two. Add the right powers to go to decimal, or divide by two repeatedly to go back, and group bits in fours whenever you want to read them as hex. For longer numbers, our converter does it instantly and shows the result both ways.