Binary to Decimal Converter: Complete Number System Guide
Learn how binary and decimal numbers work, how to convert between them by hand with worked examples, and where binary shows up in programming, networking and electronics.
Every number a computer stores, from a pixel's colour to your bank balance, is held in binary. Understanding how binary works, and how to convert it to and from the decimal numbers we use every day, is a core skill in programming, networking and electronics. This guide explains both systems and walks through the conversions step by step.
Binary and Decimal Basics
Decimal (base 10)
Decimal uses ten digits, 0 to 9. Each position is worth ten times the one to its right: ones, tens, hundreds, thousands. So 4,725 means:
(4 × 1,000) + (7 × 100) + (2 × 10) + (5 × 1)
Binary (base 2)
Binary uses only two digits, 0 and 1. Each position is worth twice the one to its right: 1, 2, 4, 8, 16, 32 and so on.
Computers use binary because their circuits have two reliable states: a transistor is either conducting or not, a voltage is high or low, a memory cell is charged or not.
Useful terms:
- Bit: a single binary digit (0 or 1)
- Nibble: 4 bits
- Byte: 8 bits
- Word: the number of bits a processor handles at once, typically 32 or 64 on modern computers
Converting Binary to Decimal
Method: number the positions from the right, starting at 0. Multiply each digit by 2 raised to its position, then add the results.
Example 1: 1011
Position · 3 · 2 · 1 · 0
Digit · 1 · 0 · 1 · 1
Value (2ⁿ) · 8 · 4 · 2 · 1
Digit × value · 8 · 0 · 2 · 1
8 + 0 + 2 + 1 = 11
Example 2: 101010
32 + 0 + 8 + 0 + 2 + 0 = 42
Example 3: 11111111
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, the largest number that fits in one byte.
Example 4: 10000000
Only the leftmost of the eight bits is set, so the value is 2⁷ = 128.
Powers of 2 to Remember
Power · Value · Power · Value
2⁰ · 1 · 2⁶ · 64
2¹ · 2 · 2⁷ · 128
2² · 4 · 2⁸ · 256
2³ · 8 · 2¹⁰ · 1,024
2⁴ · 16 · 2¹⁶ · 65,536
2⁵ · 32 · 2³² · 4,294,967,296
Converting Decimal to Binary
Method 1: Divide by 2
Divide the number by 2 and write down the remainder (0 or 1). Repeat with the quotient until it reaches 0. Then read the remainders from bottom to top.
Example: 13
- 13 ÷ 2 = 6, remainder 1
- 6 ÷ 2 = 3, remainder 0
- 3 ÷ 2 = 1, remainder 1
- 1 ÷ 2 = 0, remainder 1
Reading upwards: 1101
Method 2: Subtract Powers of 2
Find the largest power of 2 that fits, subtract it and write a 1 in that position. Repeat with what's left, writing 0 for positions you skip.
Example: 25
- 16 fits (25 − 16 = 9): 1 in the 16s place
- 8 fits (9 − 8 = 1): 1 in the 8s place
- 4 doesn't fit: 0
- 2 doesn't fit: 0
- 1 fits (1 − 1 = 0): 1 in the 1s place
Result: 11001
Bit Sizes and Number Ranges
The number of bits sets the range of values a computer can store:
Size · Unsigned range · Signed range (two's complement)
8-bit · 0 to 255 · −128 to 127
16-bit · 0 to 65,535 · −32,768 to 32,767
32-bit · 0 to 4,294,967,295 · −2,147,483,648 to 2,147,483,647
64-bit · 0 to about 1.8 × 10¹⁹ · about ±9.2 × 10¹⁸
Unsigned numbers are zero or positive and use every bit for the value. Signed numbers can be negative. Almost all computers use two's complement for these, where the leftmost bit acts as the sign. Going past the top of a range causes overflow, a classic source of software bugs.
Binary Arithmetic
Addition rules:
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 1 = 10 (write 0, carry 1)
- 1 + 1 + 1 = 11 (write 1, carry 1)
Example: 1011 (11) + 0110 (6) = 10001 (17)
Multiplication works like long multiplication in decimal, but each row is either 0 or a shifted copy of the number.
Example: 101 (5) × 11 (3) = 101 + 1010 = 1111 (15)
Hexadecimal and Octal: Binary Shorthand
Long binary numbers are hard to read, so programmers often use:
- Hexadecimal (base 16): digits 0–9 and A–F. Each hex digit stands for exactly 4 bits. To convert, split the binary number into groups of four from the right. Example: 1101 0111 → D (13) and 7 → D7. Hex is used for colours (#FF8800), memory addresses and byte values.
- Octal (base 8): digits 0–7, each standing for 3 bits. Today it's mainly seen in Unix/Linux file permissions, such as chmod 755.
Where Binary Is Used
- Programming: bitwise operators (AND, OR, XOR, NOT and shifts) are used for flags, permissions, masks and fast multiplication or division by 2.
- Networking: an IPv4 address is 32 bits written as four decimal numbers. For example, 192.168.1.1 is 11000000.10101000.00000001.00000001. Subnet masks such as 255.255.255.0 make sense once you see them in binary.
- Text: ASCII uses 7 bits per character. UTF-8 uses 1 to 4 bytes per character, which covers every language and emoji.
- Electronics: logic gates (AND, OR, NOT, NAND, NOR, XOR) combine binary signals to build adders, memory and processors.
- Colours and images: each pixel's red, green and blue values are usually 8 bits each, from 0 to 255.
Converting in Code
- Python: int("1011", 2) gives 11; bin(11) gives '0b1011'.
- JavaScript: parseInt("1011", 2) gives 11; (11).toString(2) gives "1011".
- C, C++, Java and others: write binary literals with a 0b prefix, such as 0b1011.
On your computer, the built-in calculator also converts between bases: use Programmer mode in Windows Calculator, or the Programmer view in the macOS Calculator.
Common Mistakes
- Numbering positions from 1 instead of 0. The rightmost bit is worth 2⁰ = 1.
- Reading division remainders top to bottom. Read them from the bottom up.
- Mixing bases. Is "10" ten or two? Writing 0b10 or 10₂ for binary avoids confusion.
- Forgetting the range. 256 doesn't fit in one unsigned byte.
Conclusion
Binary is simple once you see the pattern: each position is worth double the one to its right. With that idea, you can convert any binary number to decimal by adding up powers of 2, and any decimal number to binary by dividing by 2. Practise with a few numbers of your own, and check your answers with your computer's calculator in Programmer mode.
For everyday measurement conversions, try our free Unit Converter.