How to Convert Decimal Numbers

Decimal (base-10) is the number system we use in everyday life — it evolved because humans have ten fingers. Computers, however, work in binary, display memory in hexadecimal, and use octal for Linux file permissions. Converting a decimal integer to another base always uses the same algorithm: repeated division by the target base. Each division step peels off one digit of the result, starting from the least significant. This guide explains exactly how the algorithm works and walks through fully verified examples for binary, octal, and hexadecimal output.

The Repeated Division Algorithm — How It Works

To convert a decimal integer N to base B, you repeatedly divide N by B. Each division produces a quotient (carry it forward to the next step) and a remainder (keep it as one digit of the answer). The first remainder you get is the least significant digit of the result; the last remainder is the most significant digit. Reading all the remainders from last to first gives the complete answer in base B.

  1. Divide N by the target base B. Record the remainder r₀ and the quotient q₁.
  2. Divide the quotient q₁ by B. Record the new remainder r₁ and quotient q₂.
  3. Continue dividing each successive quotient by B, recording the remainder each time.
  4. Stop when the quotient reaches 0.
  5. The answer is all collected remainders read from bottom (last) to top (first).
  6. For base 16: replace any remainder value 10–15 with the corresponding letter (A=10, B=11, C=12, D=13, E=14, F=15).

Decimal → Binary: Worked Example — Convert 89₁₀

Divide 89 by 2 repeatedly. Each remainder is one binary bit, starting from the least significant (rightmost) bit.

Dividend÷ 2QuotientRemainder (bit)
89÷ 2441 ← least significant bit
44÷ 2220
22÷ 2110
11÷ 251
5÷ 221
2÷ 210
1÷ 201 ← most significant bit
Read remainders bottom to top: 1, 0, 1, 1, 0, 0, 1 → (89)₁₀ = (1011001)₂. Verify: 64+16+8+1 = 89₁₀ ✓

Decimal → Octal: Worked Example — Convert 255₁₀

Divide 255 by 8. This number is well-known in computing — it is the maximum value of one byte (8 bits all set to 1), which appears frequently in networking and programming.

Dividend÷ 8QuotientRemainder (digit)
255÷ 8317 ← least significant digit
31÷ 837
3÷ 803 ← most significant digit
Read bottom to top: 3, 7, 7 → (255)₁₀ = (377)₈. Verify: 3×64 + 7×8 + 7 = 192+56+7 = 255₁₀ ✓

Decimal → Hexadecimal: Worked Example 1 — Convert 255₁₀

The same number (255) in hex — one byte is always two hex digits.

Dividend÷ 16QuotientRemainder (digit)
255÷ 161515 → F ← least significant digit
15÷ 16015 → F ← most significant digit
(255)₁₀ = (FF)₁₆. Verify: 15×16 + 15 = 240+15 = 255₁₀ ✓. All eight bits set to 1 (11111111₂) gives FF₁₆.

Decimal → Hexadecimal: Worked Example 2 — Convert 3454₁₀

A larger number requiring three hex digits and producing letter-valued remainders.

Dividend÷ 16QuotientRemainder (digit)
3454÷ 1621514 → E ← least significant digit
215÷ 16137
13÷ 16013 → D ← most significant digit
Read bottom to top: D, 7, E → (3454)₁₀ = (D7E)₁₆. Verify: 13×256 + 7×16 + 14 = 3328+112+14 = 3454₁₀ ✓

Why Remainders Are Read in Reverse

The first remainder from dividing N by B is the coefficient of B⁰ (the units place) — the least significant digit. The second remainder is the coefficient of B¹. The last remainder is the most significant digit. Division naturally produces digits from least significant to most significant, so reading bottom-to-top reverses that order, giving the standard most-significant-first notation.

💡Think of it like peeling an onion from the outside in. Each division strips off one digit from the right side of the answer. Reading remainders bottom-to-top reassembles the number from left (most significant) to right (least significant).

Quick Conversion Reference

DecimalBinaryOctalHex
0000
81000108
10101012A
15111117F
16100002010
64100000010040
1281000000020080
25511111111377FF

Frequently Asked Questions

Why do we read remainders from bottom to top?

The first remainder produced is the least significant digit (the units position). The last remainder produced is the most significant digit (the highest positional value). Reading bottom-to-top reverses the order of generation so the most significant digit appears first, matching the way we conventionally write numbers — from left (large) to right (small).

How do I convert a decimal fraction to binary?

For fractional parts, use repeated multiplication instead of division: multiply the fractional part by 2, take the integer part (0 or 1) as the next binary digit after the binary point, then repeat with the remaining fractional part. For example, 0.75×2=1.5 (digit 1), 0.5×2=1.0 (digit 1, done) → 0.75₁₀ = 0.11₂. Note that some fractions (like 0.1) never terminate in binary.

Is there a quick check that my conversion is correct?

Yes — convert back. After converting N₁₀ to another base, use positional notation to convert the result back to decimal and check that you get N₁₀. For example, after converting 89₁₀ to binary (1011001₂), verify: 64+16+8+1 = 89₁₀ ✓. This reverse check always works.

Does the algorithm work for any target base?

Yes — repeated division works for any integer base B ≥ 2. The only differences are: what value to divide by at each step, and what digit symbols to use for remainders ≥ 10. For bases up to 16, the convention is to use A–F for values 10–15. For larger bases (like base 64), additional symbols are needed.