How to Convert Binary Into Decimal (and Vice Versa)

By: Mark Mancini  | 
Binary code on a computer screen.
Binary code is able to tell your computer fine details about how a voice sounds, or how colors should appear. Jan Hakan Dahlstrom/Getty Images

Humans spent the last five and a half millennia inventing over 100 different ways to write down numbers. With due respect to Roman numerals, the world's favorite technique right now is — by a huge margin — the modern decimal system. Its users can express any whole number they like with just 10 little characters: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.

However, your computer takes another approach. Laptops, smartphones, and other devices rely on binary code. A mathematical language, binary relays instructions to these high-tech gizmos. It tells your computer how a podcaster's voice sounds, which colors should appear in a YouTube video, and how many letters were used in that email your boss just sent.


Binary code lives up to its name. Unlike the decimal number system, it uses only two digits, which programmers call "bits." Usually, there's "0" and there's "1." And that's all. Luckily, we'll show you how to convert a binary number into the more familiar decimal system. Then, like a good magician, we'll do the exact opposite, bringing the decimal to binary value.

Know Your Exponents

Understanding positional notation is key for dealing with both the number systems and the conversions. Every digit plays its part in the calculation, from the most significant bit to the least significant bit. Technically, 0 and 1 are the only bits you need to write binary numbers. But to make sense of them, you have to understand a third value: 2.

It's best if we explain this by way of example. The number 138 is properly expressed in binary code as "10001010." How can your computer tell this apparent string of gibberish means "138"? Programming is part of the answer. Somebody has informed your device that — in this case — the binary code spells out a number instead of a written word or sentence; there's a separate method for decoding the latter.


Once this basic fact is established, the code works by assigning a different exponent of 2 to each individual bit (i.e., every 0 and every 1). An exponent is a value multiplied by itself a certain number of times. So, 2 to the third power, written as 23, is 2 x 2 x 2, which equals 8.

Please enjoy the following powers of 2 list. Trust us, you'll want to look this over soon.

2 = 1

21 = 2

22 = 4

23 = 8

24 = 16

25 = 32

26 = 64

27 = 128

28 = 256

29 = 512

210 = 1024


Understanding the Binary Number System

Now let's go back to our original binary number: 10001010. If English is your native language, brace yourself, as you're about to fight against your instincts. See, written English is read from left to right. But now, we have to break down that binary number by going in the opposite direction: from right to left.

In any binary number, the bit that's farthest to the right has to be multiplied by 2. Then the one to its immediate left is multiplied by 21. Next, the bit to its left is multiplied by 22. And so on and so forth. Notice a pattern here? The individual exponents of 2 are being used in ascending order, from right to left.


OK, so now our job is to keep that pattern going until we've matched an exponent of 2 to every bit — every single 0 and 1— in the binary number. We'll stop once the final bit, the one on the far left side, has been multiplied by the appropriate exponent of 2.

A helpful way to keep your figures straight is to physically line up the exponents over their corresponding binary bits on a sheet of paper. Ideally, it should look something like this:

Binary to decimal
To avoid confusion, line up your binary digits and decimal numbers as per this conversion chart.


Converting Binary Numbers to Decimal Value

Good stuff. Alright, now let's return to the actual binary to decimal conversion. Because 10001010 contains 8 individual bits, we're going to do 8 separate multiplication problems. Let's begin with the 0 on the far right end. What's 0 x 2? The correct answer is 0.

One problem down, seven to go. Move one space to the left. See the "1" there? Well, 1 x 21 = 2. Now move yet another space to the left. Doing so will give you 0 x 22, which equals 0. If you continue using this pattern, proceeding from the rightmost digit to the leftmost digit, here's what you'll ascertain:


0 x 2 = 0

1 x 21 = 2

0 x 22 = 0

1 x 23 = 8

0 x 24 = 0

0 x 25 = 0

0 x 26 = 0

1 x 27 = 128


Determining the Decimal Equivalent

Hang on, we're almost at the finish line! Take the results of all those multiplication problems and add them together. Not multiply, add. Savvy? What does 0 + 2 + 0 + 8 + 0 + 0 + 0 + 128 equal?

Before we answer that, let's get rid of all those zeroes. We don't need them in an addition problem. All we really have to do is solve this puzzle: 2 + 8 + 128 = ? Guess what? The final answer is 138. Congratulations, we've come full circle! Go take a victory lap.


Note that 138 is a whole number. There is a technique for converting numbers with a fractional component, like 0.25 and 3.14, into binary. But full disclosure: It's kind of complicated. If that doesn't bother you and you'd like to learn more, the Institute of Electrical and Electronics Engineers (IEEE) offers a standardized conversion method.

Decimal Conversion Formula

Having changed "10001010" into "138," it's time to reverse our process. Suppose you'd started out with 138 and had to convert it to binary. How would you do it? Once again, exponents are the key to the whole shebang.

Have another look at our "powers of 2" list. Find the value that comes the closest to 138 without exceeding it. A quick reread tells us 138 sits between 256 (which is 28) and 128 (that's 27). Now, we're going to subtract 128 from 138. Here's the equation: 138 - 128 = 10


Next, take that 10 and have a second gander at the exponent list. The power of 2 which comes the closest to equaling 10 is 23, or 8. So at this point, our job is to subtract 8 from 10. Like so: 10 - 8 = 2. And what do you know? The number 2 is equal to 21. This process gave us three important figures: 128, 8 and 2. Our next objective is to add them up: 128 + 8 + 2 = 138.

Interpreting the Decimal Value

Find a piece of paper if you haven't already done so. Write out the value of every exponent of 2 beginning with "128" (remember, that's 27) and "1" (which equals 2). Do this in descending order from left to right. And make sure to leave some space between each number.

Your scribbling should look like this: 128 64 32 16 8 4 2 1. As you can see, there are eight individual values listed here. Draw a downward-pointing arrow (↓) below each value. Then, consult the addition problem we wrote down up above, the one that says 128 + 8 + 2 = 138.


Do you see a "128" in that problem? If so, write a "1" underneath the corresponding arrow. Is there a "64" written in the equation? Nope! So beneath that arrow, we're going to write a "0." Keep to the same pattern and you'll get this:

binary to decimal conversion
One of the best decimal conversion methods.

Look familiar? We're left with 10001010 — and as we've already established, that means "138." So there you go. In short order, you've learned the binary number system, the decimal equivalent, and how to complete the binary to decimal conversion. Then, you've used the decimal number system to dial your way back to only two digits. Our proverbial magician has made the rabbit disappear and brought it back again. Carrots all around!


Frequently Answered Questions

What is the binary number 11111111 in decimal?
The binary number 11111111 is equal to the decimal number 255.