Binary to Decimal Converter
Type a binary number to convert it to decimal instantly, with the step-by-step working: each bit, its place value and the sum. It also shows the hex and octal values, and works for long binary numbers too.
Binary number to Decimal number converter
Step by step
How to convert binary to decimal
Binary is base 2: every position is worth twice the position to its right. Reading from the right, the places are worth 1, 2, 4, 8, 16 and so on (20, 21, 22, ...). To convert:
- Write the place value above each bit, starting with 1 at the rightmost bit and doubling as you move left.
- Keep the place values that have a 1 under them and ignore the ones with a 0.
- Add the kept place values. The total is the decimal number.
Example: 101101 in decimal. The bits from left to right sit on the places 32, 16, 8, 4, 2, 1. The 1s are on 32, 8, 4 and 1, so 101101 = 32 + 8 + 4 + 1 = 45.
| Place value | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|
| Bit | 1 | 0 | 1 | 1 | 0 | 1 |
| Adds | 32 | 0 | 8 | 4 | 0 | 1 |
A shortcut (doubling): start at 0, and for each bit from left to right, double the total and add the bit. For 1011: 0×2+1 = 1, 1×2+0 = 2, 2×2+1 = 5, 5×2+1 = 11. This is also how the code below works.
Binary to decimal table
| Binary | Decimal | Binary | Decimal |
|---|---|---|---|
| 0000 | 0 | 1000 | 8 |
| 0001 | 1 | 1001 | 9 |
| 0010 | 2 | 1010 | 10 |
| 0011 | 3 | 1011 | 11 |
| 0100 | 4 | 1100 | 12 |
| 0101 | 5 | 1101 | 13 |
| 0110 | 6 | 1110 | 14 |
| 0111 | 7 | 1111 | 15 |
| Power of 2 | Binary | Decimal |
|---|---|---|
| 20 | 1 | 1 |
| 21 | 10 | 2 |
| 22 | 100 | 4 |
| 23 | 1000 | 8 |
| 24 | 10000 | 16 |
| 25 | 100000 | 32 |
| 26 | 1000000 | 64 |
| 27 | 10000000 | 128 |
| 28 | 100000000 | 256 |
| 210 | 10000000000 | 1,024 |
One byte is 8 bits, so it holds 00000000 to 11111111, which is 0 to 255 in decimal (28 = 256 values). Need octal or hex too? Use the Number Base Converter. Studying for AP Computer Science Principles? Binary numbers are part of Big Idea 2, and the AP CSP practice test has questions on them.
Convert binary to decimal in code
Most languages have a built-in for this, and the loop is short enough to write yourself. Press Run this code to try each one in the online editor.
Python
# Built-in: int() with base 2
print(int("101101", 2)) # 45
# By hand: double the total and add each bit
def binary_to_decimal(bits):
total = 0
for bit in bits:
total = total * 2 + int(bit)
return total
for bits in ["1011", "11111111", "100000000"]:
print(bits, "=", binary_to_decimal(bits))
C
#include <stdio.h>
long binary_to_decimal(const char *bits) {
long total = 0;
for (int i = 0; bits[i] != '\0'; i++) {
total = total * 2 + (bits[i] - '0');
}
return total;
}
int main(void) {
printf("%ld\n", binary_to_decimal("101101")); /* 45 */
printf("%ld\n", binary_to_decimal("11111111")); /* 255 */
return 0;
}
JavaScript
// Built-in: parseInt with radix 2
console.log(parseInt("101101", 2)); // 45
// Long binary numbers: BigInt keeps every digit
console.log(BigInt("0b" + "1".repeat(64)).toString()); // 18446744073709551615
Frequently asked questions
How do you convert binary to decimal?
Give each bit a place value, starting with 1 on the right and doubling to the left (1, 2, 4, 8, 16...). Add the place values of the bits that are 1. For example, 1011 = 8 + 2 + 1 = 11.
What is 11111111 in decimal?
255. It is eight 1s, so 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, the largest number one byte can hold.
What is 1010 in decimal?
10. The 1s are on the places 8 and 2, and 8 + 2 = 10.
Can I convert very long binary numbers?
Yes. The converter uses big integers, so 64-bit and longer binary numbers convert exactly. The step-by-step working is shown for up to 32 bits.
How do I convert binary to decimal in Python?
Use int with base 2: int("101101", 2) returns 45. The code examples on this page also show how to do it by hand with a loop.
Is this converter free?
Yes. It runs in your browser, is free and needs no account.
Related tools
- Decimal to Binary Converter with Steps - Free OnlineConvert decimal to binary instantly and see the working: divide by 2 and read the remainders. Hex, octal, two's complement and code examples. Free.
- Truth Table Generator - Step by Step, Free OnlineMake a truth table for any Boolean expression, with a column for every step. AND, OR, NOT, XOR, NAND, NOR, implies and iff; minterms, SOP and POS. Free.
- Boolean Algebra Calculator - Simplify Expressions, K-MapSimplify Boolean expressions online: minimal sum of products and product of sums, Karnaugh map, minterms, canonical forms and an equivalence check. Free.