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.
- Divide N by the target base B. Record the remainder r₀ and the quotient q₁.
- Divide the quotient q₁ by B. Record the new remainder r₁ and quotient q₂.
- Continue dividing each successive quotient by B, recording the remainder each time.
- Stop when the quotient reaches 0.
- The answer is all collected remainders read from bottom (last) to top (first).
- 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 | ÷ 2 | Quotient | Remainder (bit) |
|---|---|---|---|
| 89 | ÷ 2 | 44 | 1 ← least significant bit |
| 44 | ÷ 2 | 22 | 0 |
| 22 | ÷ 2 | 11 | 0 |
| 11 | ÷ 2 | 5 | 1 |
| 5 | ÷ 2 | 2 | 1 |
| 2 | ÷ 2 | 1 | 0 |
| 1 | ÷ 2 | 0 | 1 ← most significant bit |
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 | ÷ 8 | Quotient | Remainder (digit) |
|---|---|---|---|
| 255 | ÷ 8 | 31 | 7 ← least significant digit |
| 31 | ÷ 8 | 3 | 7 |
| 3 | ÷ 8 | 0 | 3 ← most significant digit |
Decimal → Hexadecimal: Worked Example 1 — Convert 255₁₀
The same number (255) in hex — one byte is always two hex digits.
| Dividend | ÷ 16 | Quotient | Remainder (digit) |
|---|---|---|---|
| 255 | ÷ 16 | 15 | 15 → F ← least significant digit |
| 15 | ÷ 16 | 0 | 15 → F ← most significant digit |
Decimal → Hexadecimal: Worked Example 2 — Convert 3454₁₀
A larger number requiring three hex digits and producing letter-valued remainders.
| Dividend | ÷ 16 | Quotient | Remainder (digit) |
|---|---|---|---|
| 3454 | ÷ 16 | 215 | 14 → E ← least significant digit |
| 215 | ÷ 16 | 13 | 7 |
| 13 | ÷ 16 | 0 | 13 → D ← most significant digit |
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.
Quick Conversion Reference
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 64 | 1000000 | 100 | 40 |
| 128 | 10000000 | 200 | 80 |
| 255 | 11111111 | 377 | FF |
- Decimal Converter — Convert decimal integers to binary, octal, and hex with full steps
- Decimal Conversion Formula — Division algorithm formula with variable definitions and worked examples
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.