Number Base Converter
Convert between Binary, Octal, Decimal & Hexadecimal โ with live positional breakdown
How to Convert Numbers Between Binary, Octal, Decimal, and Hexadecimal
Every number you work with on a computer exists in multiple representations at the same time. The value "255" in decimal is the exact same quantity as "FF" in hexadecimal, "377" in octal, and "11111111" in binary. Computers think in binary; programmers often use hexadecimal as shorthand; and people naturally work in decimal. Understanding how to move between these bases โ and why each one exists โ is one of the most practical skills in computing, networking, and electronics.
What Is a Number Base (Radix)?
A number base, also called a radix, tells you how many distinct digit symbols a positional numbering system uses before it "rolls over" and adds a new position. Decimal uses base 10, meaning digits 0 through 9. Once you reach 9 and add 1, you carry into the next position: 9 + 1 = 10. Binary works identically, except it only has two symbols โ 0 and 1 โ so a carry happens at 2. Octal carries at 8. Hexadecimal carries at 16, which is why it borrows the letters A through F to represent the values 10 through 15 in a single digit.
The key insight is that every digit in a positional system is multiplied by its base raised to the power of its position. The rightmost digit is position 0 (base^0 = 1), the next is position 1 (base^1 = base), and so on. All conversions rely on this single rule.
Step 1 โ Converting Any Base to Decimal
The most universal path is to first convert your source number into decimal, then convert from decimal into your target base. Converting to decimal is straightforward: multiply each digit by its place value and sum them up.
Take the binary number 1011. Reading from right to left, the digits occupy positions 0, 1, 2, and 3.
- 1 ร 2โฐ = 1 ร 1 = 1
- 1 ร 2ยน = 1 ร 2 = 2
- 0 ร 2ยฒ = 0 ร 4 = 0
- 1 ร 2ยณ = 1 ร 8 = 8
Sum: 8 + 0 + 2 + 1 = 11 in decimal.
The same rule applies to hexadecimal. Take 2F. The digit F has a decimal value of 15, and 2 is just 2.
- F ร 16โฐ = 15 ร 1 = 15
- 2 ร 16ยน = 2 ร 16 = 32
Sum: 32 + 15 = 47 in decimal.
Step 2 โ Converting Decimal to Any Target Base
Going the other direction uses repeated division. Divide your decimal number by the target base, record the remainder, then divide the quotient again. The remainders, read bottom to top, form the converted number.
Convert decimal 45 to binary (base 2):
- 45 รท 2 = 22 remainder 1
- 22 รท 2 = 11 remainder 0
- 11 รท 2 = 5 remainder 1
- 5 รท 2 = 2 remainder 1
- 2 รท 2 = 1 remainder 0
- 1 รท 2 = 0 remainder 1
Reading the remainders bottom to top: 101101. Verify: 32 + 0 + 8 + 4 + 0 + 1 = 45. Correct.
Convert decimal 200 to hexadecimal (base 16):
- 200 รท 16 = 12 remainder 8
- 12 รท 16 = 0 remainder 12 (= C in hex)
Reading bottom to top: C8. Verify: 12 ร 16 + 8 = 192 + 8 = 200. Correct.
Step 3 โ The Binary-Octal-Hex Shortcut
When converting directly between binary, octal, and hexadecimal, you can skip the decimal step entirely by grouping binary digits.
Binary to Octal: Group binary digits into sets of 3 from right to left. Each group of 3 binary digits maps directly to one octal digit (since 2ยณ = 8).
Binary 101110 โ groups: 101 and 110 โ 5 and 6 โ Octal 56.
Binary to Hexadecimal: Group binary digits into sets of 4 from right to left. Each group of 4 maps to one hex digit (since 2โด = 16).
Binary 10111100 โ groups: 1011 and 1100 โ 11(=B) and 12(=C) โ Hex BC.
This shortcut makes hex a popular notation for binary data โ it compresses 8 binary digits into just 2 hex digits, keeping the information compact without losing any precision.
Step 4 โ Reading the Positional Breakdown
The breakdown panel in this converter shows you exactly what each digit contributes to the total value. Every digit card displays three things: the digit itself, the position exponent (e.g., 2ยณ), and the actual decimal value that digit adds (e.g., 8). When you add all those individual values together, you get back your original decimal number โ this is the proof that the conversion is correct.
Pay attention to zero digits. A 0 in any position contributes nothing (0 ร anything = 0), but it is still essential because it shifts the other digits into higher positions. The binary number 1000 is not the same as 1 โ the three trailing zeros push the leading 1 into the 2ยณ position, giving it a value of 8.
Common Conversions Worth Memorizing
A handful of conversions appear so frequently in computing that most programmers internalize them:
- 0xFF = 255 decimal โ the maximum value of a single unsigned byte.
- 0x00 to 0xFF โ full byte range (0โ255), used constantly in color codes (RGB), memory addressing, and network protocols.
- Binary 10000000 = 128 โ the most significant bit in an 8-bit number.
- Octal 777 = 511 decimal โ file permissions in Unix/Linux (rwxrwxrwx).
- 0x10 = 16 decimal โ one hex digit represents exactly 4 binary digits (a nibble).
Where Each Base Is Actually Used
Binary is the native language of digital hardware. Every transistor is either on (1) or off (0). All data โ text, images, video, instructions โ ultimately lives in memory as binary.
Octal was heavily used in older computing systems (PDP machines, early Unix) and survives today primarily in Unix file permissions. When you run chmod 755, you are writing an octal number: 7 = rwx, 5 = r-x.
Decimal is what humans use by default, and most user-facing values (port numbers, IP octets, array indices) are displayed in decimal.
Hexadecimal is the programmer's shorthand for binary. Memory addresses, color values (#1A2B3C in CSS), MAC addresses (A4:C3:F0:...), and error codes (0x80000003) are all written in hex because one hex digit maps cleanly to exactly four binary digits, making patterns instantly visible.
Tips for Avoiding Common Mistakes
The most frequent error is mixing up the source base. Always confirm which base you are reading from before converting โ a "10" in binary equals 2 in decimal, but a "10" in octal equals 8, and a "10" in hexadecimal equals 16. The tool on this page makes the source base explicit, which eliminates that ambiguity.
When working with hexadecimal manually, remember that A=10, B=11, C=12, D=13, E=14, F=15. Forgetting that F represents 15 (not 16) is a classic off-by-one error. Also note that hex digits are case-insensitive: "ff", "FF", and "Ff" all mean the same thing โ 255.
For binary, pad shorter numbers with leading zeros when grouping into nibbles (groups of 4) or bytes (groups of 8). The number 1101 is the same as 00001101 โ the leading zeros do not change the value but they make the grouping and alignment clearer when working with multi-byte values.