Decimal Conversion Formula – Repeated Division Algorithm

Repeated-division formula for converting decimal to binary, octal or hex, with variable definitions, steps and three worked examples.

Formula
To convert a decimal integer N to base B, repeatedly divide N by B. The remainder at each step is one digit of the result (least significant first). Continue until the quotient reaches 0, then read all collected remainders from last to first — that sequence is the number expressed in base B. For base 16, replace any remainder 10–15 with its letter (A–F).
Variables
SymbolNameDescriptionUnit
NDecimal inputThe positive integer to convert — starts as the original number and is replaced by the quotient at each step until it reaches 0—
BTarget baseThe number system to convert to: 2 for binary, 8 for octal, 16 for hexadecimal. Must be an integer ≥ 2—
qₖQuotient at step kThe integer part of dividing the previous value by B: qₖ = ⌊qₖ₋₁ / B⌋. This becomes the input to the next division step—
rₖRemainder at step kOne digit of the output: rₖ = qₖ₋₁ mod B. The first remainder r₀ is the least significant digit; the last remainder is the most significant digit—
How to Use
  1. Divide N by the target base B. Record the remainder r₀ (least significant digit) and quotient q₁.
  2. Divide q₁ by B. Record the remainder r₁ and quotient q₂.
  3. Continue dividing each successive quotient by B, recording the remainder at each step.
  4. Stop when the quotient is 0. The last remainder recorded is the most significant digit.
  5. The result is all collected remainders read from last to first (most-significant first).
  6. For base 16: replace remainders 10→A, 11→B, 12→C, 13→D, 14→E, 15→F.
Examples
1. Convert 89₁₀ to binary (divide by 2)
Dividend÷ 2QuotientRemainder (bit)
89÷ 2441
44÷ 2220
22÷ 2110
11÷ 251
5÷ 221
2÷ 210
1÷ 201
NoteRead remainders bottom to top: 1,0,1,1,0,0,1 → (89)₁₀ = (1011001)₂. Verify: 64+16+8+1 = 89₁₀ ✓
2. Convert 255₁₀ to octal (divide by 8)
Dividend÷ 8QuotientRemainder (digit)
255÷ 8317
31÷ 837
3÷ 803
NoteRead bottom to top: 3,7,7 → (255)₁₀ = (377)₈. Verify: 3×64 + 7×8 + 7 = 192+56+7 = 255₁₀ ✓
3. Convert 3454₁₀ to hexadecimal (divide by 16)
Dividend÷ 16QuotientRemainder (digit)
3454÷ 1621514 → E
215÷ 16137
13÷ 16013 → D
NoteRead bottom to top: D, 7, E → (3454)₁₀ = (D7E)₁₆. Verify: 13×256 + 7×16 + 14 = 3328+112+14 = 3454₁₀ ✓