
Number-Base Conversions
Convert a decimal number into binary, octal, or hex by repeated division.
Description
A procedure for rewriting the same quantity in another base (2, 8, 10, 16). Humans read decimal/hex easily; machines use binary. Conversion bridges the two worlds. Integer part: divide by the base, keep remainders. Fraction: multiply by the base, keep carries.
- Divide the number by the target base; record the remainder.
- Repeat on the quotient until it reaches 0.
- The answer is the remainders read from last to first.
- Multiply the fraction by the base and record the integer carry.
- Repeat on the remaining fraction until it terminates or you have enough digits.
- What: A procedure for rewriting the same quantity in another base (2, 8, 10, 16).
- Why: Humans read decimal/hex easily; machines use binary. Conversion bridges the two worlds.
- How: Integer part: divide by the base, keep remainders. Fraction: multiply by the base, keep carries.
- Where: Assemblers, debuggers, memory dumps, and any tool that shows machine values to people.
- When: Any time a value crosses the human↔machine boundary, e.g. typing an address as hex.
At a glance
What
A procedure for rewriting the same quantity in another base (2, 8, 10, 16).
Why
Humans read decimal/hex easily; machines use binary. Conversion bridges the two worlds.
How
Integer part: divide by the base, keep remainders. Fraction: multiply by the base, keep carries.
Where
Assemblers, debuggers, memory dumps, and any tool that shows machine values to people.
When
Any time a value crosses the human↔machine boundary, e.g. typing an address as hex.
Think of it like…
Like making change: you keep pulling out the biggest coin that fits and noting what's left. Repeated division 'pulls out' the next digit each time, and the leftovers (remainders) spell the answer backwards.
Repeated division (integers)
- Divide the number by the target base; record the remainder.
- Repeat on the quotient until it reaches 0.
- The answer is the remainders read from last to first.
Repeated multiplication (fractions)
- Multiply the fraction by the base and record the integer carry.
- Repeat on the remaining fraction until it terminates or you have enough digits.
Binary ↔ octal ↔ hex grouping
| Decimal | Binary | Octal (3-bit) | Hex (4-bit) |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 5 | 0101 | 5 | 5 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
Group bits in 3s for octal, 4s for hex — no division needed.
Repeated-division converter
▶ live simulator| step | value ÷ 2 | quotient | remainder |
|---|---|---|---|
| 1 | 156 ÷ 2 | 78 | 0 |
| 2 | 78 ÷ 2 | 39 | 0 |
| 3 | 39 ÷ 2 | 19 | 1 |
| 4 | 19 ÷ 2 | 9 | 1 |
| 5 | 9 ÷ 2 | 4 | 1 |
| 6 | 4 ÷ 2 | 2 | 0 |
| 7 | 2 ÷ 2 | 1 | 0 |
| 8 | 1 ÷ 2 | 0 | 1 |
Read remainders bottom-to-top → 10011100
The 5 Whys
- 1
Why convert bases? To move values between human and machine notation.
- 2
Why not just use one base everywhere? Decimal suits people; binary suits circuits.
- 3
Why hex as a middle ground? One hex digit packs exactly four bits.
- 4
Why does grouping work? Powers of the same base align cleanly (8 = 2³, 16 = 2⁴).
- 5
Root cause: base relationships let conversion be mechanical division/grouping, not guesswork.
Cheat sheet
Working principle
- Integer part: divide by the base, keep remainders. Fraction: multiply by the base, keep carries.
- A procedure for rewriting the same quantity in another base (2, 8, 10, 16).
Key facts
- Divide the number by the target base; record the remainder.
- Multiply the fraction by the base and record the integer carry.
Why it exists
- Root cause: base relationships let conversion be mechanical division/grouping, not guesswork.