How to Solve Base Conversion Problems
Convert numbers between decimal, binary, octal and hex using division-remainder and grouping shortcuts, with a worked example and practice questions.
Expected Interview Answer
Converting a number between bases means re-expressing the same quantity as a sum of powers of the new base, done by repeated division for base-to-decimal-and-back or by grouping bits for binary-hex/octal shortcuts.
To convert decimal to base b, repeatedly divide by b and read the remainders bottom-to-top; to convert base b to decimal, multiply each digit by its place value b^k and sum. Binary to hexadecimal is a direct grouping trick because 16 = 2^4: group binary digits into fours from the right and translate each group to one hex digit, no decimal detour needed. Octal works the same way with groups of three since 8 = 2^3. Fractional parts convert by repeatedly multiplying by the target base and reading off the integer parts produced each step.
- One division/remainder method handles any base pair via decimal
- Binary-hex and binary-octal grouping skips decimal entirely, saving time
- The place-value sum method generalizes cleanly to any base
AI Mentor Explanation
A scoreboard that shows runs in overs and balls is really base-6 counting for the balls part: 6 balls make 1 over, so 37 balls is 6 overs and 1 ball, found by dividing 37 by 6 and reading quotient then remainder. Converting decimal to any base b uses exactly this: divide by b repeatedly, keep the remainders, and read them from last division to first. Going the other way, 6 overs and 1 ball converts back by multiplying overs by 6 and adding the leftover ball, mirroring the place-value sum used to convert any base back to decimal.
Worked example
Divide repeatedly
- 156÷8=19 r4
- 19÷8=2 r3
- 2÷8=0 r2
Read bottom-up
- Base 8 result: 234
Verify
- 2×64+3×8+4×1 = 156
Step-by-Step Explanation
Step 1
Decimal to base b
Divide repeatedly by b, record remainders, read them bottom-to-top.
Step 2
Base b to decimal
Multiply each digit by b raised to its place-value power, then sum.
Step 3
Binary to hex/octal shortcut
Group binary digits into 4s (hex) or 3s (octal) from the right and translate each group directly.
Step 4
Fractional parts
Multiply the fraction by the target base repeatedly, reading off integer parts produced each step.
What Interviewer Expects
- Correct repeated-division algorithm for decimal-to-base conversion
- Correct place-value summation for base-to-decimal conversion
- Knowledge of the binary-hex/octal grouping shortcut and why it works (powers of 2)
- Correct handling of fractional parts using repeated multiplication
Common Mistakes
- Reading the remainders top-to-bottom instead of bottom-to-top
- Using the wrong grouping size for binary-to-hex (must be 4) or binary-to-octal (must be 3)
- Forgetting to pad leading zeros when grouping binary digits
- Mixing up multiplication and division steps between the two conversion directions
Best Answer (HR Friendly)
“Base conversion is just re-expressing the same number using different place values. Going from any base to decimal, multiply each digit by its place value and add them up. Going from decimal to another base, divide repeatedly by that base and read the remainders backwards. For binary to hex or octal specifically, there is a shortcut: just group the binary digits into fours or threes and translate each group directly, since 16 and 8 are powers of 2.”
Follow-up Questions
- Why does the binary-to-hexadecimal grouping shortcut use groups of exactly 4 bits?
- How would you convert a number directly between two non-decimal bases, like base 5 to base 7?
- How do you convert a fractional decimal number into binary?
- What is 2's complement and how does it relate to base conversion for negative numbers?
MCQ Practice
1. Convert decimal 45 to binary.
45 = 32+8+4+1 = 101101 in binary (verify: 45÷2=22 r1, 22÷2=11 r0, 11÷2=5 r1, 5÷2=2 r1, 2÷2=1 r0, 1÷2=0 r1, read bottom-up: 101101).
2. Convert binary 11010110 to hexadecimal using the grouping shortcut.
Group into 4s: 1101 0110 → 1101=13=D, 0110=6, so the result is D6.
3. What is octal 47 in decimal?
4×8 + 7×1 = 32+7 = 39.
Flash Cards
Decimal to base b method? — Repeatedly divide by b, read remainders bottom-to-top.
Base b to decimal method? — Sum each digit times b raised to its place-value power.
Binary-to-hex shortcut? — Group binary digits into 4s from the right, translate each group to one hex digit.
Fractional decimal to base b? — Multiply the fraction by b repeatedly, read off integer parts produced.