How to Convert Binary to Decimal (and Hex): Step by Step

To convert binary to decimal, multiply each bit by its place value and add the results. The place values are powers of 2 that double from right to left: 1, 2, 4, 8, 16 and so on. For example, 1011 in binary is 1×8 + 0×4 + 1×2 + 1×1 = 8 + 0 + 2 + 1 = 11.

Try it free: Integer Base Converter Free to use, no account needed.

This guide shows how to convert binary to decimal with two methods, how to go the other way from decimal to binary, what hexadecimal is and why programmers use it, and how to switch between binary, hex and octal without a calculator. Every example below was checked with code. To check your own numbers as you read, paste them into the free Binary Converter.

How to read binary: place values

Binary code is information written with only two symbols, 0 and 1. Computers use it because their circuits work with two states, such as low and high voltage. Each binary digit is called a bit, and a group of 8 bits is a byte.

Binary is a positional system, just like decimal. In decimal, each position is worth 10 times the one to its right (ones, tens, hundreds). In binary, each position is worth 2 times the one to its right:

Position (from the right)8th7th6th5th4th3rd2nd1st
Power of 22⁷2⁶2⁵2⁴2³2²2¹2⁰
Place value1286432168421

A 1 means "include this place value" and a 0 means "skip it".

How to convert binary to decimal step by step

Method 1: add the place values

Take the binary number 11010110. Write the place values under the bits, keep the ones where the bit is 1, and add them:

Bit11010110
Place value1286432168421
Bit × value128640160420

128 + 64 + 16 + 4 + 2 = 214. So 11010110₂ = 214₁₀. The small subscript shows the base when it isn't obvious.

Method 2: double and add

This method needs no table. Start with 0, then read the bits from left to right: double the running total and add the current bit.

For 101101:

  1. 0 × 2 + 1 = 1
  2. 1 × 2 + 0 = 2
  3. 2 × 2 + 1 = 5
  4. 5 × 2 + 1 = 11
  5. 11 × 2 + 0 = 22
  6. 22 × 2 + 1 = 45

So 101101₂ = 45. Check it with method 1: 32 + 8 + 4 + 1 = 45.

How to convert decimal to binary

Repeated division by 2

Divide the number by 2, write down the remainder (0 or 1), and repeat with the quotient until it reaches 0. Then read the remainders from the bottom up. Here is 156:

DivisionQuotientRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Reading upward gives 156 = 10011100₂. Check: 128 + 16 + 8 + 4 = 156. The most common mistake is reading the remainders top-down, which gives the bits in reverse order.

Subtracting powers of 2

For small numbers it is often faster to take the largest power of 2 that fits, subtract it, and repeat. For 100: 64 fits (100 − 64 = 36), then 32 (36 − 32 = 4), then 4 (4 − 4 = 0). Put a 1 under 64, 32 and 4 and a 0 everywhere else: 100 = 1100100₂.

What is hexadecimal?

Hexadecimal (hex) is base 16. It needs 16 digits, so after 0–9 it uses the letters A–F for the values 10 to 15: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. Each position is worth 16 times the one to its right: 1, 16, 256, 4,096 and so on.

Programmers use hex because it lines up exactly with binary. Four bits have 16 possible patterns (0000 to 1111), so one hex digit is exactly 4 bits, and two hex digits are exactly one byte. The largest byte, 11111111, is simply FF in hex, while in decimal it is 255, a number that doesn't reveal the bit pattern. That is why memory addresses, color codes, MAC addresses and IPv6 addresses are written in hex.

How to convert hex to decimal

Use the same place-value method with powers of 16, and replace letters with their values:

How to convert decimal to hexadecimal

Decimal to hexadecimal works like decimal to binary, but you divide by 16. Remainders from 10 to 15 become the letters A to F. Here is 1000:

DivisionQuotientRemainder
1000 ÷ 16628
62 ÷ 16314 = E
3 ÷ 1603

Reading the remainders from the bottom up gives 1000 = 3E8₁₆. Check: 3 × 256 + 14 × 16 + 8 = 768 + 224 + 8 = 1000.

Binary to hexadecimal: group the bits in fours

Because one hex digit is four bits, converting binary to hexadecimal needs no arithmetic at all. Split the binary number into groups of four bits (called nibbles), starting from the right, and replace each group using this table:

BinaryHexDecimalBinaryHexDecimal
000000100088
000111100199
0010221010A10
0011331011B11
0100441100C12
0101551101D13
0110661110E14
0111771111F15

Examples:

Hex to binary works in reverse: replace each hex digit with its four bits. 3E8 → 0011 1110 1000 → 1111101000 once you drop the leading zeros.

Octal in brief

Octal is base 8 and uses the digits 0–7. It works like hex but with three-bit groups, because 2³ = 8. Its best-known use today is Unix file permissions. In chmod 755, each digit is three permission bits (read, write, execute):

So 755 in octal is the bit pattern 111 101 101, which is 493 in decimal. The Chmod Calculator turns ticked permission boxes into the octal number, or shows which permissions a number such as 755 sets.

Where you meet these conversions

Prefixes: 0b, 0x and 0o

In code, a prefix tells the compiler which base a number literal uses:

PrefixBaseExampleDecimal value
0bBinary (2)0b101111
0oOctal (8)0o755493
0xHexadecimal (16)0x3E81000

0x works in almost every language. 0b is supported in Python, JavaScript, Java, C# and C++. 0o is used by Python and JavaScript, while C and C++ write octal with a plain leading zero, so 0755 in C is 493, not 755.

Most languages can also convert strings for you:

# Python
int("1011", 2)      # 11
bin(156)            # '0b10011100'
hex(1000)           # '0x3e8'
int("3E8", 16)      # 1000

// JavaScript
parseInt("1011", 2)     // 11
(1000).toString(16)     // "3e8"
Number("0b1011")        // 11

One trap: in JavaScript, parseInt("0b1011") returns 0, because parseInt stops at the first character it can't read and doesn't understand the 0b prefix. Strip the prefix and pass the radix instead, as explained in the MDN reference for parseInt.

A note on negative numbers

Computers usually store negative integers in two's complement. To write −5 in 8 bits, start from 5 = 00000101, flip every bit to get 11111010, then add 1: 11111011. Read as an unsigned number, the same pattern is 251 (256 − 5), or FB in hex. That is why the same byte can mean −5 or 251 depending on whether the program treats it as signed.

Binary, decimal, octal and hex conversion table

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
321000004020
64100000010040
100110010014464
12711111111777F
1281000000020080
25511111111377FF
256100000000400100

Convert any base with the Binary Converter

The free Binary Converter runs in your browser. Type a number and set its base, and it shows the value in binary, octal, decimal and hexadecimal at once, plus one custom output base.

A few limits to know: it converts non-negative whole numbers only, so a minus sign or a decimal point is rejected; hex output is lowercase and without leading zeros; and the "Base64 (64)" row is a base-64 number using the digits 0–9, a–z, A–Z, + and /, not Base64 text encoding.

FAQ

What is the largest number you can store in 8 bits?

255, written as 11111111 in binary or FF in hex. Eight bits give 2⁸ = 256 different patterns, which cover 0 to 255. Sixteen bits reach 65,535, and each extra bit doubles the range.

Why do programmers use hexadecimal instead of decimal?

Because each hex digit maps to exactly four bits, you can read the bit pattern straight from the hex digits. A byte is always two hex digits (00 to FF). Decimal has no such fit: 255 and 256 look similar in decimal but are 11111111 and 100000000 in binary.

How do you convert a binary fraction to decimal?

Bits after the binary point are worth 1/2, 1/4, 1/8 and so on. So 101.11₂ = 4 + 1 + 0.5 + 0.25 = 5.75. Many decimal fractions, such as 0.1, have no exact binary form, which is why 0.1 + 0.2 isn't exactly 0.3 in most programming languages. The Binary Converter handles whole numbers only.

Is binary code the same as ASCII?

No. Binary is the number system; ASCII is a table that assigns a number to each character. The letter A is ASCII code 65, and that number is stored as the bits 01000001.

Try it free: Integer Base Converter Free to use, no account needed.