Computer ScienceChapter 1: Computer Systems
1.2.2 Conversions from one Number system to the other
To convert from any base to decimal
Explanation level
Numbers can be converted from one base to another using simple, step-by-step methods. The two main types of conversions are:
- From any base to base-10 (decimal)
- From base-10 (decimal) to any other base
Main Idea
To convert from any base to decimal, we expand the number using positional weights (powers of the base) and add the results.
To convert from decimal to any other base, we divide the integer part repeatedly by the new base and record remainders, and we multiply the fractional part repeatedly by the new base and record integer parts.
Core Concept
Conversion from any Base to Base-10 (Decimal)
To convert a number from any base to base-10 (decimal), you need to convert each digit of the number to its decimal equivalent. Then, you use base-10 arithmetic to expand the number by multiplying each digit by the base raised to the power of its position (starting from 0 on the right). Finally, add the results together to get the decimal value.
Detailed Explanation
i. Conversion from Binary to Decimal
Example 1: (10111)2 to decimal
(10111)2 = (1 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (1 × 20)
= 16 + 0 + 4 + 2 + 1
= (23)10
Example 2: (100101.1011)2 to decimal
(100101.1011)2 = (1 × 25) + (0 × 24) + (0 × 23) + (1 × 22) + (0 × 21) + (1 × 20) + (1 × 2-1) + (0 × 2-2) + (1 × 2-3) + (1 × 2-4)
= 32 + 0 + 0 + 4 + 0 + 1 + 12 + 0 + 18 + 116
= 37 + 1116
= 37 + 0.6875
= (37.6875)10
ii. Conversion from Octal to Decimal
Example: (437)8 to decimal
(437)8 = (4 × 82) + (3 × 81) + (7 × 80)
= (4 × 64) + (3 × 8) + (7 × 1)
= 256 + 24 + 7
= (287)10
iii. Conversion from Hexadecimal to Decimal
Example: (1BE8)16 to decimal
(1BE8)16 = (1 × 163) + (B × 162) + (E × 161) + (8 × 160)
= (1 × 163) + (11 × 162) + (14 × 161) + (8 × 160)
= (1 × 4096) + (11 × 256) + (14 × 16) + (8 × 1)
= 4096 + 2816 + 224 + 8
= (7144)10
Conversion from Base-10 (Decimal) to any other Base
To convert a decimal number to any other number:
- Divide the decimal number to be converted by the value of the new base and record the remainder as the LSD of the new base number.
- Divide the quotient of the previous division by the new base again and record the remainder as the next digit to the left of the new base number.
- Repeat this process until the quotient becomes zero or not divisible by the base.
Note: The last remainder obtained will be the MSD of the new base number.
i. From Decimal to Binary
- Divide the integer part by 2.
- Record the remainder (0 or 1).
- Update the integer part to the quotient.
- Repeat steps 1–3 until the integer part is 0.
- The binary representation is the remainders read in reverse order.
- Multiply the decimal part by 2.
- Record the integer part (0 or 1). This becomes the next binary digit.
- Remove the integer part from the product, leaving only the decimal part.
- Repeat the process with the new decimal part.
- Continue until the decimal part becomes 0 or until you have reached the desired precision.
- The binary representation is the sequence of recorded integers.
Example 1: (179.257)10 to binary
Step 1: Converting integer part 179 to binary
| Division | Quotient | Remainder |
|---|---|---|
| 179 ÷ 2 | 89 | 1 |
| 89 ÷ 2 | 44 | 1 |
| 44 ÷ 2 | 22 | 0 |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading remainders from bottom to top: (179)10 = (10110011)2
Step 2: Converting fractional part 0.257 to binary
| Multiplication | Result | Integer Part |
|---|---|---|
| 0.257 × 2 | 0.514 | 0 |
| 0.514 × 2 | 1.028 | 1 |
| 0.028 × 2 | 0.056 | 0 |
| 0.056 × 2 | 0.112 | 0 |
| 0.112 × 2 | 0.224 | 0 |
| 0.224 × 2 | 0.448 | 0 |
| 0.448 × 2 | 0.896 | 0 |
| 0.896 × 2 | 1.792 | 1 |
Reading integer parts from top to bottom: (0.257)10 = (0.01000001)2
So, (179.257)10 = (10110011.01000001)2
ii. From Decimal to Octal
Example 1: (165)10 to octal
| Division | Quotient | Remainder |
|---|---|---|
| 165 ÷ 8 | 20 | 5 |
| 20 ÷ 8 | 2 | 4 |
| 2 ÷ 8 | 0 | 2 |
Reading remainders from bottom to top: (165)10 = (245)8
Example 2: (331)10 to octal
| Division | Quotient | Remainder |
|---|---|---|
| 331 ÷ 8 | 41 | 3 |
| 41 ÷ 8 | 5 | 1 |
| 5 ÷ 8 | 0 | 5 |
Reading remainders from bottom to top: (331)10 = (513)8
iii. From Decimal to Hexadecimal
Example 1: (739)10 to hexadecimal
| Division | Quotient | Remainder |
|---|---|---|
| 739 ÷ 16 | 46 | 3 |
| 46 ÷ 16 | 2 | 14 (E) |
| 2 ÷ 16 | 0 | 2 |
Reading remainders from bottom to top: (739)10 = (2E3)16
Example 2: (3501)10 to hexadecimal
| Division | Quotient | Remainder |
|---|---|---|
| 3501 ÷ 16 | 218 | 13 (D) |
| 218 ÷ 16 | 13 | 10 (A) |
| 13 ÷ 16 | 0 | 13 (D) |
Reading remainders from bottom to top: (3501)10 = (DAD)16
Conversion from Octal to Binary and vice versa
The conversion from Octal to Binary and vice versa is performed by converting each octal digit to its 3-bit binary equivalent. The eight possible digits are converted as follows:
| Octal digit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Binary | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
i. From Octal to Binary
Example: (7301)8 to binary
7 → 111 \] \[ 3 → 011 \] \[ 0 → 000 \] \[ 1 → 001
So, (7301)8 = (111011000001)2
ii. From Binary to Octal
Example: (1100111000101)2 to octal
- Take group of 3 binaries from the right side.
- If any one or two bits are left alone, add zeros to the left to make them group of 3.
- Convert each binary group to its equivalent Octal digit.
1100111000101 → 1\ 100\ 111\ 000\ 101
Add zeros to the leftmost group: 001\ 100\ 111\ 000\ 101
Convert: 001 → 1 100 → 4 111 → 7 000 → 0 101 → 5
So, (1100111000101)2 = (14705)8
Conversion from Hexadecimal to Binary and vice versa
The conversion from Hexadecimal to Binary and vice versa is performed by converting each hexadecimal digit to its 4-bit binary equivalent.
| Hexadecimal | Binary | Hexadecimal | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A (10) | 1010 |
| 3 | 0011 | B (11) | 1011 |
| 4 | 0100 | C (12) | 1100 |
| 5 | 0101 | D (13) | 1101 |
| 6 | 0110 | E (14) | 1110 |
| 7 | 0111 | F (15) | 1111 |
i. From Hexadecimal to Binary
Example: (D73A1)16 to binary
D → 13 → 1101 \] \[ 7 → 7 → 0111 \] \[ 3 → 3 → 0011 \] \[ A → 10 → 1010 \] \[ 1 → 1 → 0001
So, (D73A1)16 = (11010111001110100001)2
ii. From Binary to Hexadecimal
Example: (110011100100110101)2 to hexadecimal
- Take group of 4 binaries from the right side.
- If any one, two or three bits are left alone, add zeros to the left to make them group of 4.
- Convert each binary group to its equivalent Hexadecimal digit.
110011100100110101 → 11\ 0011\ 1001\ 0011\ 0101
Add zeros to the leftmost group: 0011\ 0011\ 1001\ 0011\ 0101
Convert: 0011 → 3 0011 → 3 1001 → 9 0011 → 3 0101 → 5
So, (110011100100110101)2 = (33935)16
Conversion from Octal to Hexadecimal and vice versa
i. From Octal to Hexadecimal
- Convert Octal to Decimal number.
- Then convert the decimal number to Hexadecimal.
- Convert Octal to Binary number.
- Then convert the binary number to Hexadecimal.
Example: (6457)8 to hexadecimal
Method 1: (6457)8 = (3375)10 (3375)10 = (D2F)16 So, (6457)8 = (D2F)16
Method 2: (6457)8 = (110100101111)2 (110100101111)2 = (D2F)16 So, (6457)8 = (D2F)16
ii. From Hexadecimal to Octal
- Convert Hexadecimal to Decimal number.
- Then convert the decimal number to Octal.
- Convert Hexadecimal to Binary number.
- Then convert the binary number to Octal.
Example: (A09D)16 to octal
Method 1: (A09D)16 = (41117)10 (41117)10 = (120235)8 So, (A09D)16 = (120235)8
Method 2: (A09D)16 = (1010000010011101)2 (1010000010011101)2 = (120235)8 So, (A09D)16 = (120235)8
Important Points
- - To convert from any base to decimal: multiply each digit by base^position and add.
- - To convert from decimal to any base: divide integer part by base and record remainders; multiply fractional part by base and record integer parts.
- - Octal ↔ Binary: group bits in 3s.
- - Hexadecimal ↔ Binary: group bits in 4s.
- - Octal ↔ Hexadecimal: go through decimal or binary.
Remember
- - Read remainders bottom to top when converting from decimal to any base.
- - Read integer parts top to bottom when converting fractional parts.
- - Group from right to left when converting binary to octal or hexadecimal.
- - Pad with zeros on the left if the leftmost group is short.
- - Hexadecimal digits A–F = 10–15.
Common Mistakes
- - Reading remainders in the wrong order (must be bottom to top).
- - Forgetting to pad with zeros when grouping binary bits.
- - Using the wrong grouping size (3 for octal, 4 for hexadecimal).
- - Confusing the symbols A–F with decimal values.
- - Forgetting to include negative powers for fractional parts.
- - Mixing up MSD and LSD positions.
Quick Revision
- To decimal: sum of (digit × baseposition)
- From decimal: divide integer part, multiply fractional part.
- Octal to binary: each octal digit → 3-bit binary.
- Binary to octal: group 3 bits from right, pad left.
- Hex to binary: each hex digit → 4-bit binary.
- Binary to hex: group 4 bits from right, pad left.
- Octal to hex: via decimal or binary.
- Hex to octal: via decimal or binary.
60-Second Revision
- Any base → Decimal: multiply each digit by base^position, add.
- Decimal → Any base: divide integer part, record remainders bottom-to-top; multiply fractional part, record integer parts top-to-bottom.
- Octal ↔ Binary: 3-bit groups.
- Hex ↔ Binary: 4-bit groups.
- Octal ↔ Hex: go through decimal or binary.
- Warning: Always pad with zeros on the left when grouping bits.
Did you understand this topic?
Your answer is saved with your learning record. It does not mark the topic as mastered.
Quick revision
Revision Zone
Review the key facts, formulas and checks before you move on.1.2.2 Conversions from one Number system to the other
Sticky Notes · Quick Revision
Key Point 1
- Any base → Decimal: expand with powers.
Key Point 2
- Decimal → Any base: divide and record remainders.
Key Point 3
- Fractional part: multiply and record integer parts.
Key Point 4
- Octal ↔ Binary: 3 bits per digit.
Key Point 5
- Hex ↔ Binary: 4 bits per digit.
Key Point 6
- Read remainders bottom to top.
Same supplied content as this Notes page (shared canonical source).