Number System Conversions — Complete Guide — VLSI Trainers
Digital Electronics · Number System Conversions
Number System Conversions — Complete Guide
Every conversion you need — Decimal, Binary, Octal, Hexadecimal, BCD, Gray code, Excess-3 — with the step-by-step method, two fully worked examples per conversion, and practice problems to test yourself.
Golden rule: Binary is the bridge. When converting between Octal, Hex, and BCD — convert to binary first, then to the target. Most conversion mistakes happen from trying to jump directly between non-standard bases.
🗺️ Quick Reference — All Conversion Paths
From
To
Method
Shortcut?
Decimal
Binary
Repeated division by 2 (read remainders upward)
—
Binary
Decimal
Sum of positional weights (1×2⁰ + 1×2¹ + …)
—
Decimal
Octal
Repeated division by 8 (read remainders upward)
Via binary: group 3 bits each
Octal
Decimal
Sum of positional weights (×8⁰, ×8¹, ×8²…)
—
Decimal
Hex
Repeated division by 16 (read remainders upward)
Via binary: group 4 bits each
Hex
Decimal
Sum of positional weights (×16⁰, ×16¹…)
—
Binary
Octal
Group bits in 3s from right; convert each group
✓ Direct — 3 bits = 1 octal digit
Octal
Binary
Replace each octal digit with its 3-bit binary
✓ Direct
Binary
Hex
Group bits in 4s from right; convert each group
✓ Direct — 4 bits = 1 hex digit
Hex
Binary
Replace each hex digit with its 4-bit binary
✓ Direct
Octal
Hex
Octal → Binary → Hex
Via binary
Hex
Octal
Hex → Binary → Octal
Via binary
Decimal
BCD
Convert each decimal digit independently to 4-bit binary
✓ Digit by digit
BCD
Decimal
Group bits in 4s; convert each group to decimal digit
✓ Direct
Binary
Gray
MSB same; each bit = previous Gray XOR current binary
✓ XOR formula
Gray
Binary
MSB same; each binary bit = previous binary XOR current Gray
✓ XOR formula
BCD
Excess-3
Add 0011 to each 4-bit BCD group
✓ +3 each digit
Excess-3
BCD
Subtract 0011 from each 4-bit XS-3 group (or add 1101)
✓ −3 each digit
Memorise these digit mappings: Hex A=10, B=11, C=12, D=13, E=14, F=15. Octal uses only 0–7. BCD only uses 0000–1001 (0–9); codes 1010–1111 are illegal. Gray code MSB = Binary MSB always.
🔄 Decimal ↔ Binary
METHODDecimal → Binary | Repeated Division by 2
Steps: Divide the decimal number by 2. Write down the remainder (0 or 1). Divide the quotient by 2 again. Repeat until quotient = 0. Read the remainders from bottom to top — that is the binary equivalent.
Example 1 — Convert 45₁₀ to binary
45 ÷ 2 = 22 R 1 ← LSB
22 ÷ 2 = 11 R 0
11 ÷ 2 = 5 R 1
5 ÷ 2 = 2 R 1
2 ÷ 2 = 1 R 0
1 ÷ 2 = 0 R 1 ← MSB
45₁₀ = 101101₂
Example 2 — Convert 173₁₀ to binary
173 ÷ 2 = 86 R 1 ← LSB
86 ÷ 2 = 43 R 0
43 ÷ 2 = 21 R 1
21 ÷ 2 = 10 R 1
10 ÷ 2 = 5 R 0
5 ÷ 2 = 2 R 1
2 ÷ 2 = 1 R 0
1 ÷ 2 = 0 R 1 ← MSB
173₁₀ = 10101101₂
METHODBinary → Decimal | Positional Weight Sum
Steps: Write the positional weight (2⁰, 2¹, 2², …) under each bit from right to left. Multiply each bit by its weight. Sum all products where the bit is 1.
Key fact: 2³ = 8. So every group of 3 binary bits maps to exactly 1 octal digit and vice versa. This makes Binary↔Octal the fastest of all conversions — no arithmetic needed, just substitution.
METHODBinary → Octal | Group 3 bits from right, convert each group
Steps: Starting from the rightmost (LSB) bit, group bits in sets of 3. Pad with leading zeros on the left if needed. Convert each group of 3 to its octal equivalent (000→0 … 111→7).
METHODOctal → Binary | Replace each digit with 3-bit binary
Steps: Replace each octal digit with its exact 3-bit binary equivalent. Always use 3 bits per digit — pad with leading zeros if needed (e.g. 2 → 010, not just 10).
Key fact: 2⁴ = 16. Every group of 4 binary bits maps to exactly 1 hex digit. This is why hex is used to write binary values compactly — 1010 1111 0011 1100 is 16 characters as binary but just AF3C in hex.
METHODBinary → Hexadecimal | Group 4 bits from right, convert each group
Steps: Group bits in 4s from right. Pad left with zeros. Convert each group using the table: 0000=0, 0001=1, …, 1001=9, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F.
Integer vs fractional parts: Convert integer and fractional parts separately, then combine. For the integer part use repeated division (as above). For the fractional part use repeated multiplication.
METHODDecimal Fraction → Binary | Repeated Multiplication by 2
Steps: Multiply the fractional part by 2. The integer part of the result (0 or 1) is the next binary digit. Use only the new fractional part for the next step. Read digits from top to bottom (left to right after the binary point). Stop when fraction = 0 or enough digits obtained.
Example 1 — Convert 0.6875₁₀ to binary
0.6875 × 2 = 1.375 → bit 1
0.375 × 2 = 0.75 → bit 0
0.75 × 2 = 1.5 → bit 1
0.5 × 2 = 1.0 → bit 1 ✓ done
0.6875₁₀ = 0.1011₂
Non-terminating fractions: Not all decimal fractions terminate in binary. 0.1₁₀ = 0.000110011…₂ (repeating). Stop after the required number of binary places. This is why floating-point arithmetic can have rounding errors.
METHODBinary Fraction → Decimal | Negative Powers of 2
Weights after binary point: 2⁻¹ = 0.5, 2⁻² = 0.25, 2⁻³ = 0.125, 2⁻⁴ = 0.0625, 2⁻⁵ = 0.03125. Multiply each bit by its weight and sum.
BCD rule: Each decimal digit is encoded independently as its 4-bit binary value. The number 365 in BCD is three separate 4-bit groups — one each for 3, 6, and 5. BCD is NOT the same as binary — 365₁₀ = 0011 0110 0101 in BCD but = 101101101 in binary.
METHODDecimal → BCD | Encode each digit as 4-bit binary
METHODGray Code → Binary | XOR each bit with the PREVIOUS BINARY bit
Formula: B[n-1] = G[n-1] (MSB unchanged). B[i] = B[i+1] ⊕ G[i] for all other positions. Work left to right — each binary bit depends on the PREVIOUSLY CALCULATED binary bit.
XS-3 rule: XS-3 = BCD + 0011 (add 3 to each 4-bit BCD group). To go back, subtract 3 (add 1101 and ignore carry, or just subtract 3 in binary). Each decimal digit is handled independently.
METHODBCD → Excess-3 | Add 0011 to each 4-bit group
METHODExcess-3 → BCD | Subtract 0011 from each 4-bit group
Note: Subtracting 0011 is the same as adding its 2’s complement 1101 (and ignoring any carry out), or just subtracting 3 directly from the decimal equivalent of each 4-bit group.
Common mistake alert: BCD and binary are NOT the same! 95₁₀ = 1001 0101 in BCD but = 101 1111 in binary. Always convert BCD → Decimal → Binary → Hex, not BCD → Hex directly. Or: BCD → Decimal → Hex (divide by 16).
Interview tip: In an interview, always state which method you’re using before you start: “I’ll use the repeated-division-by-2 method…” or “Since binary-to-hex is direct, I’ll group in 4s from the right…”. This shows structured thinking and gives you a moment to recall the steps. For Gray code, say “MSB stays the same, then XOR each bit with its left neighbour” — examiners love to see you explain as you go.