In the world of computers and digital electronics, numbers are represented in various forms called number systems. Unlike the everyday decimal system we use, computers primarily use the binary system. However, octal and hexadecimal systems are also widely used as shorthand forms for binary numbers. Understanding these number systems and how to convert between them is fundamental for anyone preparing for competitive exams in computer aptitude.
Why do we need conversions? Because different systems are useful in different contexts. For example, humans find decimal numbers easy to read, but computers operate using binary. Octal and hexadecimal simplify binary representation, making it easier to read and write large binary numbers.
This section will guide you step-by-step through the basics of number systems and teach you how to convert numbers between decimal, binary, octal, and hexadecimal systems with clear examples and practical tips.
A number system is a way to represent numbers using a set of digits and a base (or radix). The base tells us how many unique digits, including zero, the system uses.
| Number System | Base (Radix) | Digit Range | Example Number |
|---|---|---|---|
| Decimal | 10 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 | 156 |
| Binary | 2 | 0, 1 | 10011100 |
| Octal | 8 | 0, 1, 2, 3, 4, 5, 6, 7 | 234 |
| Hexadecimal | 16 | 0-9, A(10), B(11), C(12), D(13), E(14), F(15) | 2F |
Note: In hexadecimal, letters A to F represent decimal values 10 to 15.
Converting numbers between different bases can be done using systematic methods. Two main approaches are:
Let's understand these methods with the help of a flowchart.
graph TD A[Start] --> B{Conversion Type?} B -->|Decimal to Other Base| C[Divide number by base] C --> D[Record remainder] D --> E{Is quotient zero?} E -->|No| C E -->|Yes| F[Write remainders in reverse order] F --> G[Result: Number in new base] B -->|Other Base to Decimal| H[Multiply each digit by base^position] H --> I[Sum all products] I --> J[Result: Decimal number]Why these methods?
The division-remainder method works because when you divide a decimal number by the base repeatedly, the remainders represent the digits of the new base starting from the least significant digit (rightmost). The positional value method works because each digit in a number represents a value multiplied by the base raised to the power of its position.
Step 1: Divide 156 by 2 and record the remainder.
156 / 2 = 78, remainder = 0
Step 2: Divide the quotient 78 by 2.
78 / 2 = 39, remainder = 0
Step 3: Continue dividing and recording remainders:
Step 4: Write the remainders in reverse order (from last to first):
Binary: 10011100
Answer: Decimal 156 = Binary 10011100
Step 1: Write the positional values of each binary digit from right to left, starting at position 0:
Positions: 5 4 3 2 1 0
Digits: 1 0 1 1 0 1
Step 2: Multiply each digit by \(2^{position}\):
Step 3: Add all the products:
32 + 0 + 8 + 4 + 0 + 1 = 45
Answer: Binary 101101 = Decimal 45
Step 1: Identify the decimal values of each hex digit:
Step 2: Write the positional values (right to left, starting at 0):
Positions: 1 0
Digits: 2 F
Step 3: Multiply each digit by \(16^{position}\):
Step 4: Add the results:
32 + 15 = 47
Answer: Hexadecimal 2F = Decimal 47
Step 1: Divide 255 by 16 and record the remainder.
255 / 16 = 15, remainder = 15
Step 2: Divide the quotient 15 by 16.
15 / 16 = 0, remainder = 15
Step 3: Write the remainders in reverse order:
Remainders: 15, 15
Step 4: Convert remainders to hex digits:
Answer: Decimal 255 = Hexadecimal FF
Step 1: Understand that each octal digit corresponds to exactly 3 binary digits (bits).
Step 2: Convert each octal digit to its 3-bit binary equivalent:
Step 3: Concatenate the binary groups:
011 100 101
Answer: Octal 345 = Binary 011100101 (or simply 11100101 without leading zero)
When to use: When converting between binary and octal or hexadecimal to save time and reduce errors.
When to use: During base conversions involving octal and hexadecimal.
When to use: When converting decimal numbers to binary using division-remainder method.
When to use: While simplifying Boolean expressions to avoid mistakes.
Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.
Go to practice →