CS Atlas GATE 2027
Digital Logic course
0 / 57 complete

Digital Logic/Phase 0 · Number Systems from Zero

Lesson 0.1.2 · Item 3 of 57

Octal, hexadecimal and converting between any two bases

Read at your own pace. Try the questions before opening the answers.

On this page

0 · Recall Warm-up

Answer from memory first. Answers are in the Answer Vault at the bottom.

1 · The Hook

🎣

A 32-bit memory address written in binary is a 32-character string: easy to mistype, hard to read. Programmers group the bits in fours and write each group as one hexadecimal digit, so the address shrinks to 8 characters. GATE asks conversions between bases 2, 8, 10 and 16, fractions that never end, and "find the base" puzzles.

2 · Predict First

🤔

Hexadecimal uses digits 0–9 and then A = 10, B = 11, …, F = 15. What is 2A₁₆ in decimal?

Make a guess in your head. The answer opens Section 3.

3 · Core Concept

💡

Predict First — the answer

2 × 16 + 10 = 42.

🗣️

In plain words

A number system with base r uses the digits 0 to r − 1, and each place is worth r times the place to its right. Binary is base 2, octal base 8, decimal base 10, hexadecimal base 16. Because 8 = 2³ and 16 = 2⁴, one octal digit is exactly 3 bits and one hex digit exactly 4 bits, so those conversions are just regrouping.

1. Any base r → decimal

Value = Σ digit × r^(position), positions 0, 1, 2, … to the left of the point and −1, −2, … to the right.

  • 175₈ = 1 × 64 + 7 × 8 + 5 = 125.
  • 3AF₁₆ = 3 × 256 + 10 × 16 + 15 = 943.
  • 10110.01₂ = 16 + 4 + 2 + 0.25 = 22.25.

2. Decimal → base r

  • Integer part: divide by r repeatedly, read remainders bottom-up (as in Lesson 0.1.1).
  • Fraction part: multiply by r repeatedly; each time the whole-number part that appears is the next digit, read top-down; keep only the fraction and continue.

0.625 → ×2 = 1.25 (1), 0.25 × 2 = 0.5 (0), 0.5 × 2 = 1.0 (1) → 0.101₂. Some fractions never end: 0.1 → 0.000110011… (the block 0011 repeats for ever). A fraction p/q (in lowest terms) ends in base r only if every prime factor of q divides r. In binary that means q must be a power of 2.

3. Binary ↔ octal and hex (regrouping)

  • Group bits in 3s (octal) or 4s (hex) starting at the point, going left for the integer part and right for the fraction; pad with zeros at the ends.
  • 1101101₂ → 001 101 101 → 155₈; → 0110 1101 → 6D₁₆.
  • Octal ↔ hex: go through binary. 1217₈ = 001 010 001 111 → 0010 1000 1111 = 28F₁₆.
Hex0123456789ABCDEF
Binary0000000100100011010001010110011110001001101010111100110111101111

4. "Find the base" puzzles

Write each number as a polynomial in the unknown base b and solve. Remember every digit must be smaller than b.

  • 24 + 17 = 40 in base b: (2b + 4) + (b + 7) = 4b → b = 11. (Digit 7 needs b > 7 ✓.)
  • 121_b = 144₈ = 100: b² + 2b + 1 = 100 → (b + 1)² = 100 → b = 9.

4 · Visual

Regrouping 1011011101 (binary)

hex  :  10 | 1101 | 1101    ->  0010 1101 1101  ->  2 D D
octal:  1 | 011 | 011 | 101 ->  001 011 011 101 ->  1 3 3 5
          ^ pad the leftmost group with zeros

5 · Worked Examples

Example 1 Easy

Convert 2A₁₆ to decimal.

Solution

2 × 16 + 10 = 42.

Example 2 Medium

Convert 0.625 to binary.

Solution

0.625 × 2 = 1.25 → 1; 0.25 × 2 = 0.5 → 0; 0.5 × 2 = 1.0 → 1 → 0.101₂.

Example 3 GATE

Convert 1217₈ to hexadecimal.

Solution

Binary 001 010 001 111 → regroup in 4s: 0010 1000 1111 → 28F₁₆.

6 · GATE Traps

⚠️

  • Fraction digits are read top-down (first product's digit first); integer digits bottom-up.
  • Group from the point outward; padding goes on the far left (integer) or far right (fraction).
  • In "find the base" questions, reject a base that is not larger than every digit used.
  • Hex letters: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

7 · Memory Hook

🧠

"Integers: divide, read up. Fractions: multiply, read down. Octal = 3 bits, hex = 4 bits."

8 · Connect the Dots

We can now write numbers in any base. The next lesson does arithmetic directly in binary (add, subtract, multiply) and sees what happens when a result needs more bits than we have.

9 · Self-Test

GATE format. Try every question before opening the vault.

Q1NAT1 markOctal to decimal

What is 175₈ in decimal?

Numerical answer: ________

Q2MCQ1 markHex to binary

3AF₁₆ in binary is:

  • (A) 1110101111
  • (B) 1110111010
  • (C) 1010111011
  • (D) 1101011111

Q3MCQ2 marksFraction

0.375 in binary is:

  • (A) 0.11
  • (B) 0.011
  • (C) 0.101
  • (D) 0.0011

Q4NAT2 marksFind the base

In some base b, 24 + 17 = 40. What is b?

Numerical answer: ________

Q5MCQ2 marksOctal to hex

1217₈ in hexadecimal is:

  • (A) 2E7
  • (B) 1A7F
  • (C) 28F
  • (D) 297

10 · Rule Card

  • Base r: digits 0 … r − 1; value = Σ digit × r^position (negative positions after the point).
  • Decimal → base r: integer part by repeated division (read up), fraction by repeated multiplication (read down).
  • Octal = groups of 3 bits, hex = groups of 4, grouped from the point; octal ↔ hex via binary.
  • p/q terminates in base r only if q's prime factors divide r (binary: q a power of 2).
  • Find-the-base: write polynomials in b, solve, keep b > every digit.

11 · Concept Ledger

Unlocked in this lesson. From here on, these terms may be used.

base (radix)octalhexadecimalpositional value with fractionsrepeated multiplication for fractionsnon-terminating fractionsregrouping bits for octal and hexoctal to hex via binaryfind-the-base equations

12 · Answer Vault

Answer Vault

Try the questions first. Open when you are ready to check.

Recall Warm-up

  • 2ⁿ − 1.

Self-Test

Q1 Answer: 1251 mark

64 + 56 + 5.

Re-read: Lesson 0.1.2 — Octal, hexadecimal and converting between any two bases

Q2 Answer: (A)1 mark

3 = 0011, A = 1010, F = 1111 → 0011 1010 1111.

  • (B) is wrong: Mangled.
  • (C) is wrong: Mangled.
  • (D) is wrong: Digits in the wrong groups.

Re-read: Lesson 0.1.2 — Octal, hexadecimal and converting between any two bases

Q3 Answer: (B)2 marks

0.375 × 2 = 0.75 → 0; 0.75 × 2 = 1.5 → 1; 0.5 × 2 = 1 → 1.

  • (A) is wrong: That is 0.75.
  • (C) is wrong: That is 0.625.
  • (D) is wrong: That is 0.1875.

Re-read: Lesson 0.1.2 — Octal, hexadecimal and converting between any two bases

Q4 Answer: 112 marks

2b + 4 + b + 7 = 4b.

Re-read: Lesson 0.1.2 — Octal, hexadecimal and converting between any two bases

Q5 Answer: (C)2 marks

Through binary: 001010001111.

  • (A) is wrong: Wrong grouping.
  • (B) is wrong: Too long.
  • (D) is wrong: Converted digit by digit, which is wrong.

Re-read: Lesson 0.1.2 — Octal, hexadecimal and converting between any two bases

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.