Home › Binary to Decimal Conversion Explained

Binary to Decimal Conversion Explained

Binary is base 2. Decimal is base 10. The conversion is just addition once you know the weight of each bit position.

A student I used to tutor called this "the addition trick," which is a fair name for it. Every binary number is a row of 1s and 0s, each position worth a fixed amount. Add up the positions holding a 1, skip the ones holding a 0, and that sum is the decimal value. Nothing else is involved. The method scales to numbers of any length, though the 8-bit byte is the version you will run into constantly.

Binary earns the name base 2 because each column is a power of 2, the same way decimal columns are powers of 10: ones, tens, hundreds, moving right to left. Swap the base and the logic carries over unchanged.

Try it: paste a binary number, get the decimal value
Works on up to 32 digits of 0s and 1s, no spaces.

Reading the Weights

An 8-bit binary number has eight positions. Reading from right to left, the weights are:

Bit position (right = 0) Power of 2 Decimal weight
Position 0 (rightmost)201
Position 1212
Position 2224
Position 3238
Position 42416
Position 52532
Position 62664
Position 7 (leftmost)27128

The binary column in the table above matches the 8-bit encoding in binary-ascii-reference-2026.csv, the same file the site's full ASCII reference table is built from.

The leftmost bit (position 7) is called the most significant bit, often abbreviated MSB. The rightmost bit (position 0) is the least significant bit, or LSB. Read left to right and the weights run 128, 64, 32, 16, 8, 4, 2, 1. Once that row is memorised, most conversions under 256 take a few seconds.

First Example: 00001010

Take the binary number 00001010. Write the weights across the top, then note which positions have a 1 bit:

1286432168421
00001010

Positions with a 1 are at weight 8 and weight 2. Add them: 8 + 2 = 10. So 00001010 in binary equals 10 in decimal.

Worth noting: the number 10 in decimal looks nothing like the number 10 in binary (00001010). That confusion trips people up constantly. When reading binary, always make the base explicit.

A Number With More Ones: 01100101

Now something with more 1 bits. The binary number 01100101:

1286432168421
01100101

1 bits at positions weighted 64, 32, 4, and 1. Add them up: 64 + 32 + 4 + 1 = 101. The binary string 01100101 is 101 decimal. That also happens to be the ASCII code for lowercase "e", but that is a coincidence we will cover in a separate article.

The Ceiling: 11111111

All eight bits set to 1. This is the maximum value an 8-bit number can hold:

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

That sum is 28 minus 1, which is why the maximum unsigned 8-bit value is always 255. You will see 255 constantly: the top of an RGB colour channel, the broadcast address in a /24 subnet, the 255.255.255.0 subnet mask.

All 4-Bit Values at a Glance

A 4-bit number, sometimes called a nibble, runs from 0000 to 1111. The weights shrink to just 8, 4, 2, 1. Here is the full set:

BinaryDecimalBinaryDecimal
0000010008
0001110019
00102101010
00113101111
01004110012
01015110113
01106111014
01117111115

Notice that the right column starts at 8 and the pattern of 1s and 0s in the left column just repeats in the right column with the leftmost bit flipped to 1. Once you know 0 through 7, you get 8 through 15 for free.

A Faster Way: Double and Add

The positional weight table is the most transparent approach, but it requires you to remember eight numbers. There is a faster mental shortcut called double-and-add, and it works from left to right.

Start with 0. For each bit, reading left to right: double your running total, then add the current bit value (0 or 1).

Let's run it on 01100101 (which we already know is 101):

StepBitDouble running totalAdd bitRunning total
Start0
100 x 2 = 00 + 00
210 x 2 = 00 + 11
311 x 2 = 22 + 13
403 x 2 = 66 + 06
506 x 2 = 1212 + 012
6112 x 2 = 2424 + 125
7025 x 2 = 5050 + 050
8150 x 2 = 100100 + 1101

Same answer: 101. The double-and-add method is popular in competitive programming because it generalises to binary strings of arbitrary length without needing to know the highest bit's weight in advance. For 8-bit numbers, both methods take about the same amount of time.

Where This Shows Up

A few places where binary-to-decimal shows up in practice:

Networking and IP addresses. IPv4 addresses are 32 bits, written as four 8-bit octets in decimal. The address 11000000.10101000.00000001.01 converts to 192.168.1.1. Subnet masks like 255.255.255.0 or 255.255.255.128 are also just binary numbers written in decimal. Anyone configuring static IPs or CIDR blocks runs this conversion constantly.

Unix file permissions. The chmod numeric mode is a 3-bit binary number per permission group. Mode 7 is 111 (read + write + execute). Mode 5 is 101 (read + execute, no write). The familiar chmod 755 translates as owner gets 7, group gets 5, others get 5.

Colour codes. RGB colours use three 8-bit channels. The hex colour #2563EB expands to three bytes: 0x25 = 37, 0x63 = 99, 0xEB = 235. Each byte converts from hex to binary to decimal. Understanding that route explains why colours top out at 255, and why there are exactly 16,777,216 possible 24-bit RGB values (256 cubed).

The conversion itself takes seconds once the positional weights are memorised. Most people who do it regularly remember the 128-64-32-16-8-4-2-1 row automatically after a week of practice. The tool above handles any number you throw at it; the mental method is there for when you are away from a screen.

For the opposite direction, see the decimal to binary guide. If you need to go further into hexadecimal, the binary to hexadecimal article covers that step next.

Things to Know

Everything above assumes an unsigned number, meaning every bit counts toward the magnitude and there is no sign bit. Signed integers work differently: an 8-bit signed byte using two's complement covers negative 128 through positive 127, not 0 through 255, because the leftmost bit is repurposed to mark the sign. The converter on this page, and the positional-weight method itself, only handles the unsigned case.

There is also no built-in length limit to the math itself, only to what is practical by hand. A 32-bit number has the same positional-weight logic as an 8-bit one, just with four more columns (32,768 and up) to track. JavaScript's own Number type stays exact up to 253, well past anything a person would reasonably convert by hand.

Common Questions About This Conversion

What is the positional weight of the rightmost bit in a binary number?

The rightmost bit always has a positional weight of 1 (that is, 2 to the power of 0). Moving left, each position doubles: 2, 4, 8, 16, and so on. The sequence for an 8-bit number, reading right to left, is 1, 2, 4, 8, 16, 32, 64, 128.

How many decimal values can an 8-bit binary number represent?

An 8-bit number can represent 256 distinct values, from 0 (00000000) through 255 (11111111). That comes from 2 to the power of 8. If you need signed integers (positive and negative), one bit is used for the sign, leaving 7 bits for magnitude and giving a range of -128 to +127.

Does the double-and-add method give the same answer as the positional weight method?

Yes. Both methods are mathematically equivalent. The positional weight method is easier to verify on paper because you can see each contribution separately. Double-and-add is faster to run in your head from left to right because you only need to track one running total instead of eight separate weights.

Why do IP addresses use binary to decimal conversion?

IPv4 addresses are 32 bits stored as four 8-bit groups. Each group converts to a decimal number between 0 and 255. So 11000000.10101000.00000001.00000001 becomes 192.168.1.1 in the familiar dotted format. Routers and network hardware work in binary; humans prefer decimal. The conversion bridges the two.

Can this page's converter handle numbers longer than one byte?

Yes, up to 32 bits. Paste any string of 0s and 1s with no spaces, up to 32 digits long, and it converts in one step without needing to split it into bytes first.

Cookies here just cover analytics and ad delivery, nothing more. Privacy