Courses / Application of ICT (GEN-103) – BS 1st Semester

Week 13 Theory – Number Systems: Binary, Octal, Decimal and Hexadecimal

Week 13 – Number Systems and Conversions · 90 min read · 43 MCQs to check yourself

Why number systems?

Computers store and process everything (numbers, text, images, sound) using two states – ON/OFF, high/low voltage – represented by 1 and 0. So computers use the binary number system. Octal and hexadecimal are used as short forms of long binary numbers.

Base (radix)

The base (radix) of a number system is the number of different digits it uses. The position of each digit gives it a place value (weight) that is a power of the base.

System Base Digits used Example Written as
Binary 2 0, 1 1011 (1011)₂
Octal 8 0 – 7 157 (157)₈
Decimal 10 0 – 9 245 (245)₁₀
Hexadecimal 16 0 – 9, A, B, C, D, E, F 2F (2F)₁₆

In hexadecimal: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

Place values

Decimal:  ... 10³=1000  10²=100  10¹=10  10⁰=1
Binary:   ... 2⁷=128 2⁶=64 2⁵=32 2⁴=16 2³=8 2²=4 2¹=2 2⁰=1
Octal:    ... 8³=512  8²=64  8¹=8  8⁰=1
Hex:      ... 16³=4096 16²=256 16¹=16 16⁰=1

Quick reference table

Decimal Binary Octal Hex
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10

MSB (Most Significant Bit) = leftmost bit; LSB (Least Significant Bit) = rightmost bit.

1. Decimal → Binary / Octal / Hexadecimal (repeated division)

Method: divide the decimal number repeatedly by the new base (2, 8 or 16), write down the remainders, and read them from bottom to top.

Example 1: (45)₁₀ → binary

2 | 45
2 | 22   remainder 1   ← LSB
2 | 11   remainder 0
2 |  5   remainder 1
2 |  2   remainder 1
2 |  1   remainder 0
      0   remainder 1   ← MSB
Read bottom → top:  (45)₁₀ = (101101)₂

Example 2: (156)₁₀ → octal

8 | 156
8 |  19   remainder 4
8 |   2   remainder 3
      0   remainder 2
(156)₁₀ = (234)₈

Example 3: (479)₁₀ → hexadecimal

16 | 479
16 |  29   remainder 15 → F
16 |   1   remainder 13 → D
       0   remainder 1
(479)₁₀ = (1DF)₁₆

Decimal fraction → binary (multiply by 2, take the integer parts top to bottom):

0.625 × 2 = 1.25  → 1
0.25  × 2 = 0.5   → 0
0.5   × 2 = 1.0   → 1
(0.625)₁₀ = (0.101)₂

2. Binary / Octal / Hexadecimal → Decimal (positional / expansion method)

Method: multiply each digit by its place value (base^position, counting from 0 at the right) and add.

Example 4: (101101)₂ → decimal

1×2⁵ + 0×2⁴ + 1×2³ + 1×2² + 0×2¹ + 1×2⁰
= 32 + 0 + 8 + 4 + 0 + 1 = (45)₁₀

Example 5: (234)₈ → decimal

2×8² + 3×8¹ + 4×8⁰ = 128 + 24 + 4 = (156)₁₀

Example 6: (1DF)₁₆ → decimal

1×16² + D(13)×16¹ + F(15)×16⁰ = 256 + 208 + 15 = (479)₁₀

Binary fraction → decimal: (0.101)₂ = 1×2⁻¹ + 0×2⁻² + 1×2⁻³ = 0.5 + 0 + 0.125 = (0.625)₁₀

3. Binary ↔ Octal (groups of 3 bits)

Since 8 = 2³, each octal digit = 3 binary bits.

Binary → Octal: group bits in threes from the right (add leading zeros if needed), convert each group.

(11010110)₂ →  011 010 110
                3   2   6     → (326)₈

Octal → Binary: replace each octal digit by its 3-bit binary.

(574)₈ → 5=101, 7=111, 4=100 → (101111100)₂

4. Binary ↔ Hexadecimal (groups of 4 bits)

Since 16 = 2⁴, each hex digit = 4 binary bits.

Binary → Hex: group bits in fours from the right.

(1011011101)₂ → 0010 1101 1101
                 2    D    D     → (2DD)₁₆

Hex → Binary: replace each hex digit by 4 bits.

(3AF)₁₆ → 3=0011, A=1010, F=1111 → (001110101111)₂ = (1110101111)₂

5. Octal ↔ Hexadecimal (through binary)

There is no direct grouping, so go through binary (or through decimal).

Octal → Hex: (725)₈

Octal → binary:  7=111 2=010 5=101 → 111010101
Regroup in 4s:   0001 1101 0101
Hex:              1    D    5   → (1D5)₁₆
Check: (725)₈ = 7×64 + 2×8 + 5 = 469;  (1D5)₁₆ = 256 + 208 + 5 = 469 ✓

Hex → Octal: (B6)₁₆

Hex → binary:  B=1011 6=0110 → 10110110
Regroup in 3s: 010 110 110
Octal:          2   6   6   → (266)₈
Check: (B6)₁₆ = 11×16 + 6 = 182;  (266)₈ = 128 + 48 + 6 = 182 ✓

6. Binary arithmetic (basics)

Binary addition rules

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10   (write 0, carry 1)
1 + 1 + 1 = 11 (write 1, carry 1)

Example:

   1011   (11)
 + 0110   (6)
 ------
  10001   (17)

Binary subtraction rules

0 − 0 = 0,  1 − 0 = 1,  1 − 1 = 0,  0 − 1 = 1 (borrow 1 from the next column)

Example:

   1101   (13)
 − 0110   (6)
 ------
   0111   (7)

1's complement – flip every bit (0→1, 1→0): 1's complement of 1010 = 0101. 2's complement – 1's complement + 1: 2's complement of 1010 = 0101 + 1 = 0110 (used to represent negative numbers).

Conversion summary

From → To Method
Decimal → any base Repeated division by the base; read remainders bottom → top
Any base → Decimal Multiply digits by powers of the base and add
Binary → Octal Group 3 bits from the right
Binary → Hex Group 4 bits from the right
Octal/Hex → Binary Each digit → 3 bits / 4 bits
Octal ↔ Hex Convert through binary

Representing Numbers and Letters with Binary – Crash Course #4

Number Systems (Binary, Octal, Decimal, Hex)

Number System Conversion: Binary, Decimal, Octal and Hexadecimal Explained

Short and long questions

1. Convert (156)₁₀ into octal.

Model answer

156÷8 = 19 r4; 19÷8 = 2 r3; 2÷8 = 0 r2. Answer: (234)₈.

2. Convert (479)₁₀ into hexadecimal.

Model answer

479÷16 = 29 r15 (F); 29÷16 = 1 r13 (D); 1÷16 = 0 r1. Reading bottom to top: (1DF)₁₆.

3. Convert (45)₁₀ into binary.

Model answer

45÷2 = 22 r1; 22÷2 = 11 r0; 11÷2 = 5 r1; 5÷2 = 2 r1; 2÷2 = 1 r0; 1÷2 = 0 r1. Reading remainders bottom to top: (101101)₂.

4. Convert (110110)₂ into decimal.

Model answer

1×32 + 1×16 + 0×8 + 1×4 + 1×2 + 0×1 = 32 + 16 + 4 + 2 = 54.

5. Convert (247)₁₀ into binary, octal and hexadecimal. Verify one answer by converting back to decimal.

Model answer

Binary: 247÷2 = 123 r1; 123÷2 = 61 r1; 61÷2 = 30 r1; 30÷2 = 15 r0; 15÷2 = 7 r1; 7÷2 = 3 r1; 3÷2 = 1 r1; 1÷2 = 0 r1 → bottom to top (11110111)₂. Octal: 247÷8 = 30 r7; 30÷8 = 3 r6; 3÷8 = 0 r3 → (367)₈. (Check by grouping binary: 011 110 111 → 3 6 7 ✓) Hexadecimal: 247÷16 = 15 r7; 15÷16 = 0 r15 (F) → (F7)₁₆. (Check by grouping: 1111 0111 → F 7 ✓) Verification: (F7)₁₆ = 15×16 + 7 = 240 + 7 = 247 ✓.

6. What is meant by the base (radix) of a number system? Give the bases of binary, octal, decimal and hexadecimal.

Model answer

The base is the number of distinct digits used in a number system. Binary – 2 (0, 1); octal – 8 (0–7); decimal – 10 (0–9); hexadecimal – 16 (0–9, A–F).

7. Convert (2F)₁₆ and (234)₈ into decimal.

Model answer

(2F)₁₆ = 2×16 + 15×1 = 32 + 15 = 47. (234)₈ = 2×64 + 3×8 + 4×1 = 128 + 24 + 4 = 156.

8. Convert (3AF)₁₆ into binary.

Model answer

3 = 0011, A = 1010, F = 1111 → (001110101111)₂ = (1110101111)₂.

9. Convert (11010110)₂ into octal and hexadecimal.

Model answer

Octal: group in 3s from right → 011 010 110 → (326)₈. Hex: group in 4s → 1101 0110 → (D6)₁₆.

10. Explain the methods of converting between number systems with one example of each.

Model answer

Decimal → other base: repeated division by the base, read remainders bottom to top; e.g. (13)₁₀ → 13÷2 = 6 r1, 6÷2 = 3 r0, 3÷2 = 1 r1, 1÷2 = 0 r1 → (1101)₂. Other base → decimal: multiply each digit by the base raised to its position and add; e.g. (1A)₁₆ = 1×16 + 10 = 26. Binary → octal: group in 3 bits from the right; e.g. (101110)₂ → 101 110 → (56)₈. Binary → hexadecimal: group in 4 bits; e.g. (10111010)₂ → 1011 1010 → (BA)₁₆. Octal/hex → binary: replace each digit by 3/4 bits; e.g. (47)₈ → 100 111 → (100111)₂; (C3)₁₆ → 1100 0011. Octal ↔ hexadecimal: through binary; e.g. (B6)₁₆ → 10110110 → 010 110 110 → (266)₈.

11. Convert (725)₈ into hexadecimal.

Model answer

Octal → binary: 7 = 111, 2 = 010, 5 = 101 → 111010101. Regroup in 4s from right: 0001 1101 0101 → (1D5)₁₆. (Check: both equal 469 in decimal.)

12. Explain binary addition and subtraction rules with examples. Also define 1's and 2's complement.

Model answer

Addition rules: 0+0 = 0; 0+1 = 1; 1+0 = 1; 1+1 = 10 (0 carry 1); 1+1+1 = 11 (1 carry 1). Example: 1011 (11) + 0110 (6) = 10001 (17). Subtraction rules: 0−0 = 0; 1−0 = 1; 1−1 = 0; 0−1 = 1 with a borrow from the next column. Example: 1101 (13) − 0110 (6) = 0111 (7). 1's complement: invert every bit; 1's complement of 10110 = 01001. 2's complement: add 1 to the 1's complement; 2's complement of 10110 = 01001 + 1 = 01010. Computers use 2's complement to represent negative numbers and to perform subtraction by addition.

13. Add (1011)₂ and (0110)₂.

Model answer

1011 + 0110: 1+0 = 1; 1+1 = 0 carry 1; 0+1+1 = 0 carry 1; 1+0+1 = 0 carry 1; final carry 1 → (10001)₂ (11 + 6 = 17).

This lesson ends with a quiz of 43 MCQs. Open the lesson on PrepOasis to take it and save your progress.

Previous: Week 12 Lab 12 – MS Excel: Rows, Columns, Sheets and Column Charts · Next: Week 13 Lab 13 – MS Excel: Filtering, Data Validation, Protection and Conditional Formatting

All lessons in Application of ICT (GEN-103) – BS 1st Semester