Numbers are everywhere in our daily lives - from counting money to measuring distances. But have you ever wondered how computers understand and work with numbers? The answer lies in number systems. A number system is a way to represent numbers using a set of symbols (called digits) and rules. Different number systems use different bases, which determine how many unique digits they have and how numbers are formed.
In computing, number systems are crucial because computers operate using electrical signals that can be in one of two states: ON or OFF. This binary nature means computers use the binary number system internally. However, humans usually use the decimal system. To bridge this gap, other systems like octal and hexadecimal are also used as shorthand representations of binary numbers.
In this chapter, we will explore the main number systems used in computing, understand how to convert numbers between these systems, and learn their applications. By mastering these concepts, you will be well-prepared for competitive exams and have a solid foundation in computer fundamentals.
The decimal number system is the most familiar system to us. It is also called the base-10 system because it uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
Each digit in a decimal number has a place value depending on its position, which is a power of 10. The rightmost digit represents units (100), the next digit to the left represents tens (101), then hundreds (102), and so on.
For example, the number 345 means:
Adding these gives 345.
Because of its intuitive nature and daily use, the decimal system is the starting point for understanding other number systems.
The binary number system is the foundation of all modern computing. It is a base-2 system, meaning it uses only two digits: 0 and 1. These digits are called bits, short for binary digits.
Each bit in a binary number has a place value that is a power of 2, starting from the rightmost bit (20), then 21, 22, and so on.
For example, the binary number 1011 means:
Adding these gives 8 + 0 + 2 + 1 = 11 in decimal.
Why binary? Because computers use switches that are either ON or OFF, representing 1 or 0. This makes binary the natural language of computers.
While binary is essential for computers, long binary numbers can be hard to read and write. To simplify, we use octal and hexadecimal systems as shorthand representations of binary numbers.
The octal system is base-8, using digits 0 to 7. Each octal digit corresponds exactly to 3 binary bits.
The hexadecimal system is base-16, using digits 0 to 9 and letters A to F (where A=10, B=11, ..., F=15). Each hex digit corresponds exactly to 4 binary bits.
| Octal Digit | Decimal Equivalent | Hex Digit | Decimal Equivalent |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 2 | 2 | 2 |
| 3 | 3 | 3 | 3 |
| 4 | 4 | 4 | 4 |
| 5 | 5 | 5 | 5 |
| 6 | 6 | 6 | 6 |
| 7 | 7 | 7 | 7 |
| A | 10 | ||
| B | 11 | ||
| C | 12 | ||
| D | 13 | ||
| E | 14 | ||
| F | 15 |
Because of this direct relationship, octal and hexadecimal numbers are easier to convert to and from binary, making them very useful in computer science.
Understanding how to convert numbers between decimal, binary, octal, and hexadecimal systems is essential. Let's look at the general methods.
graph TD A[Start] --> B{Convert from?} B -->|Decimal| C[Divide by base (2,8,16) repeatedly] B -->|Binary| D[Sum powers of 2 for decimal] B -->|Binary to Octal/Hex| E[Group bits (3 for octal, 4 for hex)] C --> F[Collect remainders as digits] D --> G[Multiply digits by powers of 2 and sum] E --> H[Convert each group to octal/hex digit] F --> I[Result in target base] G --> I H --> ILet's break down some common conversions:
Step 1: Divide 156 by 2 and write down the remainder.
Step 2: Write the remainders from bottom to top:
10011100
Answer: Decimal 156 = Binary 10011100
Step 1: Label each bit with its place value (powers of 2):
Bits: 1 0 1 1 0 1
Place values: 32 16 8 4 2 1
Step 2: Multiply each bit by its place value and sum:
Sum = 32 + 0 + 8 + 4 + 0 + 1 = 45
Answer: Binary 101101 = Decimal 45
Step 1: Group the binary digits into sets of 3 from right to left:
110 101
Step 2: Convert each group to decimal (octal digit):
Answer: Binary 110101 = Octal 65
Step 1: Convert each hex digit to 4-bit binary:
Step 2: Combine the binary groups:
0011 1111
Answer: Hexadecimal 3F = Binary 00111111
Step 1: Write the numbers aligned by place value:
1 0 1 1 + 1 1 0 1 ---------
Step 2: Add bit by bit from right to left, carrying over when sum exceeds 1:
Step 3: Write down the carry if any:
Carry 1 at the leftmost position.
Result: 11000
Answer: 1011 + 1101 = 11000 (binary)
When to use: When converting binary numbers to octal or hexadecimal to simplify the process.
When to use: When converting between hexadecimal and decimal or binary.
When to use: When converting decimal numbers to binary, octal, or hexadecimal.
When to use: When performing binary arithmetic operations.
When to use: During conversions and arithmetic involving binary numbers.
Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.
Go to practice →