Number Base Converter

Convert numbers between different bases: binary, octal, decimal, hexadecimal.

Binary
—
Octal
—
Decimal
—
Hex
—

Quick Examples

Number Systems

DecimalBinaryOctalHex
0000
10101012A
15111117F
16100002010
25511111111377FF

Common Uses

  • Binary: Computer programming, digital electronics
  • Octal: Unix file permissions
  • Hexadecimal: Memory addresses, color codes, assembly

What Are Number Bases?

A number base tells you how many distinct digits a counting system uses. The everyday decimal system is base 10, using the digits 0–9. But the base is just a convention: computers count in binary (base 2, digits 0–1) because their circuits have two states, programmers write memory addresses in hexadecimal (base 16, digits 0–9 plus A–F), and older systems used octal (base 8). The converter on this page translates numbers between these systems instantly.

All positional systems share one idea: each digit's value depends on its position. In 345, the 3 means three hundreds because it sits in the hundreds place. In general, a digit d in position i (counting from 0 at the right) contributes d × baseⁱ. That single rule explains every base, and it is all the converter needs to move numbers between systems.

Conversion Methods

To convert from any base to decimal, expand the number with the positional rule and add up: each digit times the base raised to its position. To convert from decimal to another base, use repeated division: divide by the target base, record each remainder, and repeat with the quotient until it reaches zero. Reading the remainders from bottom to top gives the converted number. Hexadecimal digits above 9 use letters: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

value = Σ dᵢ × baseⁱ (positions counted from 0 at the right)

Step-by-Step: Decimal to Binary

  • Step 1: Start with 45. Divide by 2: 45 ÷ 2 = 22 remainder 1.
  • Step 2: Divide the quotient by 2: 22 ÷ 2 = 11 remainder 0.
  • Step 3: Continue: 11 ÷ 2 = 5 remainder 1; 5 ÷ 2 = 2 remainder 1; 2 ÷ 2 = 1 remainder 0; 1 ÷ 2 = 0 remainder 1.
  • Step 4: Read the remainders from bottom to top: 1, 0, 1, 1, 0, 1.
  • Step 5: The answer is 101101 in binary. Check: 32 + 8 + 4 + 1 = 45.

Worked Examples

Example 1: Binary to decimal

Convert 1101 in binary. Expand by positions: 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13.

1101₂ = 13₁₀

Example 2: Hexadecimal to decimal

Convert 2F in hex. F stands for 15, so 2×16 + 15 = 32 + 15 = 47.

2F₁₆ = 47₁₀

Example 3: Decimal to hexadecimal

Convert 200 to hex with repeated division by 16: 200 ÷ 16 = 12 remainder 8. The quotient 12 is the hex digit C, and reading bottom-up gives C8.

200₁₀ = C8₁₆

Common Mistakes

  • Reading division remainders top-down instead of bottom-up, which reverses the digits.
  • Forgetting that hex letters have values: A = 10 through F = 15.
  • Dropping leading zeros that matter in fixed-width contexts like byte values.
  • Applying decimal place values (tenths, hundredths) to fractional binary numbers, where places are halves, quarters, and eighths.

Frequently Asked Questions

Why do computers use binary?

Hardware naturally has two stable states — current flowing or not, magnetized or not. Binary maps perfectly onto those states, making circuits simple and reliable.

Why is hexadecimal so popular in programming?

One hex digit represents exactly four bits, so long binary strings become short and readable. Memory addresses, color codes like #FF5733, and byte values are all conventionally written in hex.

What is octal used for today?

Mostly Unix file permissions, where each digit packs three permission bits (read, write, execute). A permission like 755 is three octal digits.

Can bases go higher than 16?

Yes — base 32 and base 64 exist for compact encoding, using letters plus extra symbols. The positional math works identically at any base.

Common Values Reference Table

Memorizing a few landmark values makes every conversion faster, because you can anchor to the nearest known value:

DecimalBinaryOctalHexWhy it matters
0000Zero in every base
81000108First 4-bit number
16100002010First 5-bit number; 10 in hex
3210000040202^5
641000000100402^6
12810000000200802^7; highest bit of a byte
25511111111377FFMaximum 8-bit value (one byte)
2561000000004001002^8; first 9-bit number
10241000000000020004002^10; one kilobyte
6553610000000000000000200000100002^16; 16-bit range size

Number Prefixes and Digit Separators

Programming languages mark the base with a prefix so the reader knows how to interpret the digits:

PrefixBaseExampleMeaning
0bBinary0b101010 in decimal
0oOctal0o755493 in decimal (Unix permission notation)
0xHexadecimal0xFF255 in decimal

A bare leading zero also means octal in C, C++, and Java (0755 is octal), which is why JavaScript and Python use the explicit 0o prefix instead. Underscores may separate digits for readability in many languages: 0b1111_0000 is the same as 0b11110000.

Shortcut: Binary and Hex Convert Directly

Because 16 = 2^4, one hex digit is exactly four binary bits — so binary and hex convert into each other without passing through decimal. This is the trick programmers actually use.

Hex to Binary: Expand Each Digit

Replace every hex digit with its 4-bit group. Convert 0x2F:

  • 2 = 0010, F = 1111
  • Put the groups together: 00101111
  • Check: 32 + 8 + 4 + 2 + 1 = 47, and 2x16 + 15 = 47.
0x2F = 00101111 in binary = 47 in decimal

Binary to Hex: Group in Fours from the Right

Convert 101101 to hex. Pad on the left to complete groups of four: 0010 1101. Then 0010 = 2 and 1101 = D.

101101 in binary = 0x2D = 45 in decimal

Binary to Octal: Group in Threes

Since 8 = 2^3, each octal digit is three bits. Convert 11110101: pad to 011 110 101, giving 3 6 5.

11110101 in binary = 365 in octal = 245 in decimal
Always group from the rightmost digit. Grouping from the left misaligns the place values — this is the single most common error in hand conversions.

Fractional Numbers in Other Bases

Bases handle fractions too: digits after the point use negative powers. In binary the places are halves, quarters, eighths (1/2, 1/4, 1/8), not tenths and hundredths.

Worked Example: Binary Fraction to Decimal

Convert 101.11 in binary. Integer part: 1x4 + 0x2 + 1x1 = 5. Fraction part: 1x(1/2) + 1x(1/4) = 0.5 + 0.25 = 0.75.

101.11 in binary = 5.75 in decimal

Worked Example: Decimal Fraction to Binary

Convert 0.625 to binary by repeated multiplication: multiply the fraction by 2 and record each integer part.

  • 0.625 x 2 = 1.25, record 1
  • 0.25 x 2 = 0.5, record 0
  • 0.5 x 2 = 1.0, record 1
  • Result: 0.101. Check: 0.5 + 0.125 = 0.625.

Bases Beyond 16

The positional math works at any base. Bases above 16 reuse the alphabet: in base 36, A = 10 through Z = 35. Example: 1Z in base 36 = 1x36 + 35 = 71 in decimal. Base 32 and base 64 are used for compact data encoding, and base 36 appears in URL shorteners. The converter's four bases (2, 8, 10, 16) cover the ones used in everyday programming and electronics.

Powers of Two Reference

PowerValuePowerValue
2^012^9512
2^122^101024
2^242^112048
2^382^124096
2^4162^138192
2^5322^1416384
2^6642^1532768
2^71282^1665536
2^8256

The number of bits needed for a value N is the smallest n with 2^n > N. For 500: 2^8 = 256 is too small, 2^9 = 512 fits, so 9 bits are needed. An n-bit unsigned number ranges from 0 to 2^n - 1.

Real-World Applications

ApplicationBase usedExample
Unix file permissionsOctalchmod 755: 7 = 111 (rwx), 5 = 101 (r-x), 5 = 101 (r-x)
Web colorsHexadecimal#FF5733: FF red, 57 green, 33 blue
Memory addressesHexadecimal0x7FFF: compact for long binary addresses
IP subnettingBinarySubnet masks like 255.255.255.0 are bit patterns
Character encodingDecimal/HexASCII 65 = 0x41 = the letter A
Digital logic designBinaryFPGA and circuit work happens bit by bit

Quick Conversion Cheat Sheet

  • Any base to decimal: multiply each digit by base^position and sum.
  • Decimal to any base: repeated division, read remainders bottom to top.
  • Binary to hex: group bits in fours from the right, convert each group.
  • Hex to binary: expand each hex digit to 4 bits.
  • Binary to octal: group bits in threes from the right, convert each group.
  • Decimal fraction to binary: repeated multiplication by 2, read integer parts top to bottom.