PATHSHALA | Computer Science, Class 8
DATA CONVERSION
A Complete Guide with Worked Examples
and a Ready Conversion Reference Tool
BINARY OCTAL DECIMAL HEX
Covers: Number Systems • Place Value • Step-by-step Conversion Methods
Worked Examples • Quick-reference Conversion Table (0-31)
Practice Exercises with Answers
Prepared for classroom teaching and self-study
Data Conversion
Number Systems and Conversion Methods
1. What is Data Conversion?
Computers store and process all data using electronic circuits that can only exist in two states —
ON or OFF. These two states are represented using the digits 1 and 0, forming the Binary
Number System. However, humans find it easier to read and write numbers in the Decimal
System (base 10) that we use every day. Data Conversion is the process of changing a number
from one number system (base) into another, so that data can move correctly between what the
computer understands and what humans understand.
Why do we need Octal and Hexadecimal too?
• Binary numbers become very long and hard to read (e.g. 205 in decimal is 11001101 in
binary).
• Octal (base 8) and Hexadecimal (base 16) act as a shorthand for binary, because 8 = 2^3
and 16 = 2^4.
• Hexadecimal is widely used in computing to represent memory addresses and colour codes
(e.g. #FF5733).
2. The Four Number Systems
System Base Digits Used Example
Binary 2 0, 1 1010
Octal 8 0–7 12
Decimal 10 0–9 10
Hexadecimal 16 0–9, A,B,C,D,E,F A
Data Conversion — Pathshala CS Class 8 | Page 1
Fig 1 — How the four number systems relate to one another
3. Understanding Place Value
Every number system works on the principle of place value — the value of a digit depends on its
position in the number, and each position represents a power of the base.
Fig 2 — Place value in the Decimal system: 3456 = 3x1000 + 4x100 + 5x10 + 6x1
Fig 3 — Place value in the Binary system: 1010 = 1x8 + 0x4 + 1x2 + 0x1 = 10
Data Conversion — Pathshala CS Class 8 | Page 2
4. Conversion Methods (Step-by-Step)
4.1 Decimal to Binary — Division Method
Divide the decimal number repeatedly by 2, noting the remainder each time, until the quotient
becomes 0. Then read the remainders from bottom to top.
Fig 4 — Converting 25 (decimal) to binary using repeated division by 2
Try it yourself: Convert 18 to Binary
18 ÷ 2 = 9 remainder 0
9 ÷ 2 = 4 remainder 1
4 ÷ 2 = 2 remainder 0
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Reading remainders bottom to top: 18(10) = 10010(2)
4.2 Binary to Decimal — Multiplication Method
Multiply each binary digit by its corresponding power of 2 (based on its position, counting from the
right starting at 0), then add all the results.
Data Conversion — Pathshala CS Class 8 | Page 3
Fig 5 — Converting 1101 (binary) to decimal
Try it yourself: Convert 10110 to Decimal
1x16 + 0x8 + 1x4 + 1x2 + 0x1
= 16 + 0 + 4 + 2 + 0
10110(2) = 22(10)
4.3 Decimal to Octal / Decimal to Hexadecimal
The same division method used for binary is used here — only the divisor changes to the base of
the target system (8 for Octal, 16 for Hexadecimal).
Example: Convert 100 to Octal (divide by 8)
100 ÷ 8 = 12 remainder 4
12 ÷ 8 = 1 remainder 4
1 ÷ 8 = 0 remainder 1
Reading bottom to top: 100(10) = 144(8)
Example: Convert 250 to Hexadecimal (divide by 16)
250 ÷ 16 = 15 remainder 10 → write as 'A'
15 ÷ 16 = 0 remainder 15 → write as 'F'
Reading bottom to top: 250(10) = FA(16)
Remember — Hexadecimal letter values
• 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F
4.4 Octal to Decimal / Hexadecimal to Decimal
Same as Binary-to-Decimal, but multiply each digit by powers of 8 (for Octal) or powers of 16 (for
Hexadecimal) instead of powers of 2.
Example: Convert 144 (Octal) to Decimal
1x8^2 + 4x8^1 + 4x8^0 = 1x64 + 4x8 + 4x1 = 64 + 32 + 4
144(8) = 100(10)
Data Conversion — Pathshala CS Class 8 | Page 4
Example: Convert FA (Hexadecimal) to Decimal
Fx16^1 + Ax16^0 = 15x16 + 10x1 = 240 + 10
FA(16) = 250(10)
Data Conversion — Pathshala CS Class 8 | Page 5
4.5 Binary ↔ Octal and Binary ↔ Hexadecimal (Grouping Method)
Since 8 = 2^3 and 16 = 2^4, binary digits can be converted to Octal or Hexadecimal quickly by
grouping them — no division needed!
● Binary to Octal: Starting from the right, group the binary digits in sets of 3. Convert each group
to its decimal value (0–7).
● Binary to Hexadecimal: Starting from the right, group the binary digits in sets of 4. Convert
each group to its decimal/letter value (0–F). Add leading zeros to complete the last group if
needed.
● Octal/Hex to Binary (reverse): Convert each octal digit into a 3-bit binary group, or each hex
digit into a 4-bit binary group, and join them together.
Fig 6 — Grouping binary digits to get Octal and Hexadecimal directly
Example: Convert 101(2) to Octal digit-wise (Octal to Binary reverse)
Octal 5 → Binary group = 101 (since 5 = 4+0+1 = 1x4 + 0x2 + 1x1)
So Octal 27 → 2=010, 7=111 → joined: 27(8) = 010111(2)
5. Quick-Reference Conversion Tool
Use the table below as a ready-made conversion tool for numbers 0 to 31. Simply find your
number in the Decimal column and read across to get its Binary, Octal and Hexadecimal
equivalents — no calculation needed!
Data Conversion — Pathshala CS Class 8 | Page 6
Dec Bin Oct Hex Dec Bin Oct Hex
0 00000 0 0 16 10000 20 10
1 00001 1 1 17 10001 21 11
2 00010 2 2 18 10010 22 12
3 00011 3 3 19 10011 23 13
4 00100 4 4 20 10100 24 14
5 00101 5 5 21 10101 25 15
6 00110 6 6 22 10110 26 16
7 00111 7 7 23 10111 27 17
8 01000 10 8 24 11000 30 18
9 01001 11 9 25 11001 31 19
10 01010 12 A 26 11010 32 1A
11 01011 13 B 27 11011 33 1B
12 01100 14 C 28 11100 34 1C
13 01101 15 D 29 11101 35 1D
14 01110 16 E 30 11110 36 1E
15 01111 17 F 31 11111 37 1F
How to use this tool
• To convert Decimal → Binary/Octal/Hex: find the decimal number on the left, read across the
row.
• To convert Binary/Octal/Hex → Decimal: scan the Bin/Oct/Hex column for a match, read the
Dec value in that row.
• For numbers beyond 31, use the step-by-step division or grouping methods explained in
Section 4.
Data Conversion — Pathshala CS Class 8 | Page 7
6. Practice Exercise
Answer the following questions in your notebook:
1. Convert 37 (Decimal) to Binary using the division method. Show all steps.
2. Convert 101101 (Binary) to Decimal using the multiplication method.
3. Convert 90 (Decimal) to Octal and to Hexadecimal.
4. Convert 3F (Hexadecimal) to Decimal.
5. Group 11010110(Binary) into 3-bit sets to find its Octal equivalent, and into 4-bit sets to find
its Hexadecimal equivalent.
6. Using the Quick-Reference Table, write the Binary and Hexadecimal equivalents of Decimal
27.
7. A student writes a colour code as #1A2B3C in a design program. Which number system is
this written in, and why do you think computers use it for colour codes?
Answer Key
1. 37(10) = 100101(2)
2. 101101(2) = 45(10)
3. 90(10) = 132(8) and 90(10) = 5A(16)
4. 3F(16) = 63(10)
5. 11010110 → Octal: 326(8) | Hexadecimal: D6(16)
6. 27(10) = 11011(2) = 1B(16)
7. This is Hexadecimal — used because two hex digits compactly represent one byte (8 bits)
of colour data.
Data Conversion — Pathshala CS Class 8 | Page 8