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

FromToMethodShortcut?
DecimalBinaryRepeated division by 2 (read remainders upward)
BinaryDecimalSum of positional weights (1×2⁰ + 1×2¹ + …)
DecimalOctalRepeated division by 8 (read remainders upward)Via binary: group 3 bits each
OctalDecimalSum of positional weights (×8⁰, ×8¹, ×8²…)
DecimalHexRepeated division by 16 (read remainders upward)Via binary: group 4 bits each
HexDecimalSum of positional weights (×16⁰, ×16¹…)
BinaryOctalGroup bits in 3s from right; convert each group✓ Direct — 3 bits = 1 octal digit
OctalBinaryReplace each octal digit with its 3-bit binary✓ Direct
BinaryHexGroup bits in 4s from right; convert each group✓ Direct — 4 bits = 1 hex digit
HexBinaryReplace each hex digit with its 4-bit binary✓ Direct
OctalHexOctal → Binary → HexVia binary
HexOctalHex → Binary → OctalVia binary
DecimalBCDConvert each decimal digit independently to 4-bit binary✓ Digit by digit
BCDDecimalGroup bits in 4s; convert each group to decimal digit✓ Direct
BinaryGrayMSB same; each bit = previous Gray XOR current binary✓ XOR formula
GrayBinaryMSB same; each binary bit = previous binary XOR current Gray✓ XOR formula
BCDExcess-3Add 0011 to each 4-bit BCD group✓ +3 each digit
Excess-3BCDSubtract 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

METHOD Decimal → 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₂
METHOD Binary → 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.
Example 1 — Convert 1011010₂ to decimal
Bit:    1  0  1  1  0  1  0
Weight: 64 32 16  8  4  2  1

= 64+0+16+8+0+2+0
1011010₂ = 90₁₀
Example 2 — Convert 11001101₂ to decimal
Bit:    1  1  0  0  1  1  0  1
Weight:128 64 32 16  8  4  2  1

= 128+64+0+0+8+4+0+1
11001101₂ = 205₁₀

🔄 Decimal ↔ Octal

METHOD Decimal → Octal  |  Repeated Division by 8
Steps: Divide by 8 repeatedly. Collect remainders (0–7) from bottom to top. Same as decimal-to-binary but divide by 8 instead of 2.
Example 1 — Convert 255₁₀ to octal
255 ÷ 8 = 31  R 7  ← LSD
 31 ÷ 8 =  3  R 7
  3 ÷ 8 =  0  R 3  ← MSD
255₁₀ = 377₈
Example 2 — Convert 748₁₀ to octal
748 ÷ 8 = 93  R 4  ← LSD
 93 ÷ 8 = 11  R 5
 11 ÷ 8 =  1  R 3
  1 ÷ 8 =  0  R 1  ← MSD
748₁₀ = 1354₈
METHOD Octal → Decimal  |  Positional Weight Sum (powers of 8)
Steps: Multiply each octal digit by its positional weight (8⁰=1, 8¹=8, 8²=64, 8³=512…). Sum all products.
Example 1 — Convert 347₈ to decimal
3×8² + 4×8¹ + 7×8⁰
= 3×64 + 4×8 + 7×1
= 192 + 32 + 7
347₈ = 231₁₀
Example 2 — Convert 2765₈ to decimal
2×8³ + 7×8² + 6×8¹ + 5×8⁰
= 2×512 + 7×64 + 6×8 + 5×1
= 1024 + 448 + 48 + 5
2765₈ = 1525₁₀

🔄 Decimal ↔ Hexadecimal

METHOD Decimal → Hexadecimal  |  Repeated Division by 16
Steps: Divide by 16 repeatedly. Remainders 10–15 become A–F. Read remainders bottom to top.
Example 1 — Convert 478₁₀ to hex
478 ÷ 16 = 29  R 14 → E  ← LSD
 29 ÷ 16 =  1  R 13 → D
  1 ÷ 16 =  0  R  1 → 1  ← MSD
478₁₀ = 1DE₁₆
Example 2 — Convert 3055₁₀ to hex
3055 ÷ 16 = 190  R 15 → F  ← LSD
 190 ÷ 16 =  11  R 14 → E
  11 ÷ 16 =   0  R 11 → B  ← MSD
3055₁₀ = BEF₁₆
METHOD Hexadecimal → Decimal  |  Positional Weight Sum (powers of 16)
Steps: Convert A–F to 10–15 first. Multiply each digit by its weight (16⁰=1, 16¹=16, 16²=256, 16³=4096…). Sum all products.
Example 1 — Convert 3AF₁₆ to decimal
3×16² + A×16¹ + F×16⁰
= 3×256 + 10×16 + 15×1
= 768 + 160 + 15
3AF₁₆ = 943₁₀
Example 2 — Convert C4B2₁₆ to decimal
C×16³ + 4×16² + B×16¹ + 2×16⁰
= 12×4096 + 4×256 + 11×16 + 2×1
= 49152 + 1024 + 176 + 2
C4B2₁₆ = 50354₁₀

Binary ↔ Octal  (Fastest method — 3 bits = 1 octal digit)

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.
METHOD Binary → 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).
Example 1 — Convert 10110111₂ to octal
010 | 110 | 111
 ↓     ↓     ↓
 2     6     7
10110111₂ = 267₈
(padded 0 on left)
Example 2 — Convert 111010011₂ to octal
111 | 010 | 011
 ↓     ↓     ↓
 7     2     3
111010011₂ = 723₈
METHOD Octal → 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).
Example 1 — Convert 574₈ to binary
  5   |  7   |  4
101   | 111  | 100
574₈ = 101111100₂
Example 2 — Convert 3064₈ to binary
  3   |  0   |  6   |  4
011   | 000  | 110  | 100
3064₈ = 011000110100₂
     = 11000110100₂

Binary ↔ Hexadecimal  (4 bits = 1 hex digit)

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.
METHOD Binary → 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.
Example 1 — Convert 101101111000₂ to hex
1011 | 0111 | 1000
  ↓      ↓      ↓
  B      7      8
101101111000₂ = B78₁₆
Example 2 — Convert 1111010011₂ to hex
0011 | 1101 | 0011
  ↓      ↓      ↓
  3      D      3
1111010011₂ = 3D3₁₆
(padded 00 on left)
METHOD Hexadecimal → Binary  |  Replace each digit with 4-bit binary
Steps: Replace each hex digit with its exact 4-bit binary equivalent. Always 4 bits — pad (e.g. 3 → 0011, A → 1010, F → 1111).
Example 1 — Convert 5E9₁₆ to binary
  5   |  E   |  9
0101  | 1110 | 1001
5E9₁₆ = 0101 1110 1001₂
Example 2 — Convert FA2D₁₆ to binary
  F   |  A   |  2   |  D
1111  | 1010 | 0010 | 1101
FA2D₁₆ = 1111 1010 0010 1101₂

🔄 Octal ↔ Hexadecimal  (always via binary)

METHOD Octal → Hex  |  Octal → Binary (3-bit groups) → Hex (4-bit groups)
Example 1 — Convert 5174₈ to hex
Step 1: Octal → Binary
  5   |  1   |  7   |  4
101   | 001  | 111  | 100
= 101001111100₂

Step 2: Binary → Hex (group 4)
1010 | 0111 | 1100
  A  |  7   |  C
5174₈ = A7C₁₆
Example 2 — Convert 7352₈ to hex
Step 1: Octal → Binary
  7   |  3   |  5   |  2
111   | 011  | 101  | 010
= 111011101010₂

Step 2: Binary → Hex (group 4)
1110 | 1110 | 1010
  E  |  E   |  A
7352₈ = EEA₁₆
METHOD Hex → Octal  |  Hex → Binary (4-bit groups) → Octal (3-bit groups)
Example 1 — Convert 2BC₁₆ to octal
Step 1: Hex → Binary
  2   |  B   |  C
0010  | 1011 | 1100
= 001010111100₂

Step 2: Binary → Octal (group 3)
001 | 010 | 111 | 100
 1  |  2  |  7  |  4
2BC₁₆ = 1274₈
Example 2 — Convert F4A₁₆ to octal
Step 1: Hex → Binary
  F   |  4   |  A
1111  | 0100 | 1010
= 111101001010₂

Step 2: Binary → Octal (group 3)
111 | 101 | 001 | 010
 7  |  5  |  1  |  2
F4A₁₆ = 7512₈

🔢 Fractional Conversions

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.
METHOD Decimal 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₂
Example 2 — Convert 25.375₁₀ to binary
Integer 25:
25÷2=12 R1, 12÷2=6 R0
 6÷2=3  R0,  3÷2=1 R1
 1÷2=0  R1 → 11001

Fraction 0.375:
0.375×2=0.75 → 0
0.75 ×2=1.5  → 1
0.5  ×2=1.0  → 1 done
25.375₁₀ = 11001.011₂
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.
METHOD Binary 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.
Example 1 — Convert 0.10110₂ to decimal
1×2⁻¹ + 0×2⁻² + 1×2⁻³ + 1×2⁻⁴ + 0×2⁻⁵
= 0.5 + 0 + 0.125 + 0.0625 + 0
0.10110₂ = 0.6875₁₀
Example 2 — Convert 11.011₂ to decimal
Integer: 1×2¹ + 1×2⁰ = 2 + 1 = 3
Fraction: 0×2⁻¹ + 1×2⁻² + 1×2⁻³
        = 0 + 0.25 + 0.125 = 0.375
11.011₂ = 3.375₁₀

🔟 Decimal ↔ BCD (8421 Code)

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.
METHOD Decimal → BCD  |  Encode each digit as 4-bit binary
Example 1 — Convert 4729₁₀ to BCD
 4    |  7   |  2   |  9
0100  | 0111 | 0010 | 1001
4729₁₀ = 0100 0111 0010 1001 BCD
Example 2 — Convert 308₁₀ to BCD
 3    |  0   |  8
0011  | 0000 | 1000
308₁₀ = 0011 0000 1000 BCD
METHOD BCD → Decimal  |  Group 4 bits, convert each to decimal digit
Note: If any 4-bit group is 1010–1111 (10–15) it is an INVALID BCD code. Valid BCD groups are only 0000–1001 (0–9).
Example 1 — Convert 0111 0101 0011 BCD to decimal
0111 | 0101 | 0011
  7  |   5  |   3
0111 0101 0011 BCD = 753₁₀
Example 2 — Convert 1001 0000 0110 BCD to decimal
1001 | 0000 | 0110
  9  |   0  |   6
1001 0000 0110 BCD = 906₁₀

🔁 Binary ↔ Gray Code

Gray code rule: Only one bit changes between consecutive code words. MSB of Gray = MSB of binary (always). Use XOR (⊕) for all other bits.
METHOD Binary → Gray Code  |  XOR each bit with the bit to its LEFT
Formula: G[n-1] = B[n-1] (MSB unchanged). G[i] = B[i+1] ⊕ B[i] for all other positions. Work from left to right.
Example 1 — Convert 1011₂ to Gray
Binary:  1  0  1  1
         ↓  ↓  ↓  ↓
Gray:    1  1  1  0

G₃ = B₃         = 1
G₂ = B₃ ⊕ B₂  = 1⊕0 = 1
G₁ = B₂ ⊕ B₁  = 0⊕1 = 1
G₀ = B₁ ⊕ B₀  = 1⊕1 = 0
1011₂ = 1110 Gray
Example 2 — Convert 10110₂ to Gray
Binary:  1  0  1  1  0
         ↓  ↓  ↓  ↓  ↓
G₄ = 1
G₃ = 1⊕0 = 1
G₂ = 0⊕1 = 1
G₁ = 1⊕1 = 0
G₀ = 1⊕0 = 1
10110₂ = 11101 Gray
METHOD Gray 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.
Example 1 — Convert 1101 Gray to binary
Gray:    1  1  0  1
B₃ = G₃         = 1
B₂ = B₃ ⊕ G₂  = 1⊕1 = 0
B₁ = B₂ ⊕ G₁  = 0⊕0 = 0
B₀ = B₁ ⊕ G₀  = 0⊕1 = 1
1101 Gray = 1001₂
Example 2 — Convert 11010 Gray to binary
Gray:    1  1  0  1  0
B₄ = 1
B₃ = 1⊕1 = 0
B₂ = 0⊕0 = 0
B₁ = 0⊕1 = 1
B₀ = 1⊕0 = 1
11010 Gray = 10011₂

BCD ↔ Excess-3 (XS-3)

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.
METHOD BCD → Excess-3  |  Add 0011 to each 4-bit group
Example 1 — Convert BCD of 46 to XS-3
BCD(4) = 0100 → +0011 = 0111
BCD(6) = 0110 → +0011 = 1001
46₁₀ in XS-3 = 0111 1001
Example 2 — Convert BCD of 589 to XS-3
BCD(5) = 0101 → +0011 = 1000
BCD(8) = 1000 → +0011 = 1011
BCD(9) = 1001 → +0011 = 1100
589₁₀ in XS-3 = 1000 1011 1100
METHOD Excess-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.
Example 1 — Convert 1010 0101 XS-3 to BCD
1010 → −0011 = 0111 → BCD 7
0101 → −0011 = 0010 → BCD 2
1010 0101 XS-3 = 72₁₀
Example 2 — Convert 1100 1000 0100 XS-3 to BCD
1100 → −0011 = 1001 → BCD 9
1000 → −0011 = 0101 → BCD 5
0100 → −0011 = 0001 → BCD 1
1100 1000 0100 XS-3 = 951₁₀

🔄 BCD ↔ Hexadecimal  (via binary)

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).
METHOD BCD → Hex  |  BCD → Decimal → Hex
Example 1 — Convert BCD 0111 0101 to hex
BCD → Decimal:
0111 = 7,  0101 = 5
→ 75₁₀

Decimal → Hex:
75 ÷ 16 = 4 R 11 (B)
 4 ÷ 16 = 0 R 4
BCD 0111 0101 = 4B₁₆
Example 2 — Convert BCD 1001 0011 0111 to hex
BCD → Decimal:
1001=9, 0011=3, 0111=7
→ 937₁₀

Decimal → Hex:
937 ÷ 16 = 58 R 9
 58 ÷ 16 =  3 R 10 (A)
  3 ÷ 16 =  0 R 3
BCD 1001 0011 0111 = 3A9₁₆
METHOD Hex → BCD  |  Hex → Decimal → BCD
Example 1 — Convert 2F₁₆ to BCD
Hex → Decimal:
2×16 + 15 = 47₁₀

Decimal → BCD:
4 → 0100
7 → 0111
2F₁₆ = 0100 0111 BCD
Example 2 — Convert C5₁₆ to BCD
Hex → Decimal:
12×16 + 5 = 197₁₀

Decimal → BCD:
1 → 0001
9 → 1001
7 → 0111
C5₁₆ = 0001 1001 0111 BCD

✏️ Practice Problems

Click any card to reveal the answer. Work through the problem first!

Decimal → Binary

118₁₀ = ?₂
1110110
÷2 repeatedly, read remainders upward
200₁₀ = ?₂
11001000
÷2 repeatedly
57₁₀ = ?₂
111001
÷2 repeatedly
255₁₀ = ?₂
11111111
All 1s for 2⁸−1

Binary → Decimal

110101₂ = ?₁₀
53
32+16+0+4+0+1
10000001₂ = ?₁₀
129
128+1
11110000₂ = ?₁₀
240
128+64+32+16
1010101₂ = ?₁₀
85
64+16+4+1

Decimal → Hex

500₁₀ = ?₁₆
1F4
500÷16=31 R4; 31÷16=1 R15(F)
256₁₀ = ?₁₆
100
256 = 16²
175₁₀ = ?₁₆
AF
175÷16=10(A) R15(F)
4095₁₀ = ?₁₆
FFF
16³−1 = FFF

Binary ↔ Octal

10111₂ = ?₈
27
010|111 → 2|7
654₈ = ?₂
110101100
6→110, 5→101, 4→100
11101011₂ = ?₈
353
011|101|011 → 3|5|3
207₈ = ?₂
10000111
2→010, 0→000, 7→111

Binary ↔ Gray Code

1100₂ → Gray
1010
1; 1⊕1=0; 1⊕0=1; 0⊕0=0 → wrong. Try: G=1,1⊕1=0,0⊕0=0,0⊕… redo with formula
0110₂ → Gray
0101
G₃=0; 0⊕1=1; 1⊕1=0… wait: 0;0⊕1=1;1⊕1=0;1⊕0=1 → 0101
1010 Gray → Binary
1100
B₃=1; 1⊕0=1; 1⊕1=0; 0⊕0=0
0111 Gray → Binary
0101
B₃=0; 0⊕1=1; 1⊕1=0; 0⊕1=1

BCD, XS-3, and Mixed

836₁₀ → BCD
1000 0011 0110
8→1000, 3→0011, 6→0110
0100 1000 BCD → Decimal
48
0100=4, 1000=8
BCD of 73 → XS-3
1010 0110
0111+0011=1010; 0011+0011=0110
1011 0100 XS-3 → Decimal
81
1011-0011=1000(8); 0100-0011=0001(1)
9A₁₆ → Decimal
154
9×16 + 10 = 154
154₁₀ → BCD
0001 0101 0100
1→0001, 5→0101, 4→0100
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.
Scroll to Top