Data Representation (8hrs) · Computer Fundamentals & Emerging Technologies

Conversion among binary, octal, and hexadecimal systems

Watch lectures

Conversion among binary, octal, and hexadecimal systems

1. The Key Relationship

Octal and hexadecimal are not independent of binary — they are shorthand for it, because their bases are powers of 2:

8=23,16=248 = 2^{3}, 16 = 2^{4}
System Bits per digit Grouping rule
Binary ↔ Octal 3 Group the bits in 3s
Binary ↔ Hex 4 Group the bits in 4s

Because the grouping is exact, binary ↔ octal/hex conversion needs no division — you simply re-group the bits, which is why programmers use octal/hex to write machine code and addresses compactly.

2. Binary to Octal

Group from the LSB towards the MSB in threes; pad the most significant group with zeros if it is short. For fractions, group from the binary point to the right, padding the last group.

Example: (1011101)2(1011101)_2

Grouping 001 011 101
Octal digit 1 3 5

(1011101)2=(135)8(1011101)_2 = (135)_8

With a fraction: (1 011 101 . 110 1)2(1\ 011\ 101\ .\ 110\ 1)_2 → integer 1|011|101 = 135, fraction 110|100 (padded) = .64 → 135.64₈

3. Octal to Binary

Replace each octal digit by its 3-bit equivalent (write leading zeros as needed).

Example: (745)8→111 100 101=(111100101)2(745)_8 → 111\ 100\ 101 = (111100101)_2

4. Binary to Hexadecimal

Group from the LSB in fours and replace each group by its hex symbol (A-F for 10-15).

Example: (101110101101)2(101110101101)_2

Grouping 1011 1010 1101
Hex B A D

(101110101101)2=(BAD)16(101110101101)_2 = (BAD)_{16}

5. Hexadecimal to Binary

Expand each hex digit into 4 bits.

Example: (2F5)16=0010 1111 0101=(1011110101)2(2F5)_{16} = 0010\ 1111\ 0101 = (1011110101)_2
(A3)16=1010 0011(A3)_{16} = 1010\ 0011 — note that each hex digit always produces 4 bits, even if the leading bit is 0.

6. Octal ↔ Hexadecimal (through binary)

There is no power relationship between 8 and 16, so convert via binary (or via decimal):

(72)8→111 010→0011 1010→(3A)16(72)_8 → 111\ 010 → 0011\ 1010 → (3A)_{16}
(3A)16→0011 1010→111 010→(72)8(3A)_{16} → 0011\ 1010 → 111\ 010 → (72)_8

7. Decimal to Octal / Hexadecimal — Repeated Division

Divide by the base and read the remainders upwards.

Example: (431)10=(?)8(431)_{10} = (?)_{8}

Division Quotient Remainder
431 ÷ 8 53 7
53 ÷ 8 6 5
6 ÷ 8 0 6

431₁₀ = 657₈

Example: (431)10=(?)16(431)_{10} = (?)_{16}

Division Quotient Remainder
431 ÷ 16 26 15 = F
26 ÷ 16 1 10 = A
1 ÷ 16 0 1

431₁₀ = 1AF₁₆

8. Quick Reference Table

Decimal Binary (4-bit) Octal Hex
8 1000 10 8
10 1010 12 A
15 1111 17 F
16 1 0000 20 10
255 1111 1111 377 FF
256 1 0000 0000 400 100

9. Common Mistakes to Avoid

  • Grouping from the left (MSB) instead of the right — the LSB group must be complete (pad on the left).
  • Using 4-bit groups for octal or 3-bit groups for hex.
  • Forgetting to pad the fractional group at the right end.
  • Writing a valid hex digit sequence but forgetting that A-F are single digits (10-15).

10. Exam Points

  • Convert binary to octal and hex and back, showing the grouping — 5 marks, almost certain.
  • Convert a decimal number to octal and hexadecimal by repeated division — 5 marks.
  • Why is hex a shorthand for binary but octal is not a shorthand of hex? — 3 marks.
  • Convert an octal number to hexadecimal via binary — 3-5 marks.
  • Given a number in one base, express it in all four bases — 5 marks.
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.

← All Computer Fundamentals & Emerging Technologies modules

Conversion among binary, octal, and hexadecimal systems — Computer Fundamentals & Emerging Technologies — PYQDeck