Numbers are a fundamental part of our daily lives, whether we are counting money in INR, measuring distances in metres, or telling time. But have you ever wondered how computers understand numbers? Computers use different number systems to represent and process data efficiently. A number system is a way to express numbers using a set of symbols and a base, also called radix.
The base or radix of a number system tells us how many unique digits or symbols it uses before starting to count with an additional digit. For example, the decimal system (which we use every day) has a base of 10, meaning it uses digits from 0 to 9. When we reach 9, we add another digit to represent 10.
Computers, however, work differently. They use electronic circuits that recognize two states: ON and OFF. This binary nature makes the binary number system (base 2) the most natural choice for computers. Besides binary, other number systems like octal (base 8) and hexadecimal (base 16) are also used in computing for convenience and compact representation.
Understanding these number systems and how to convert between them is essential for grasping how computers store, process, and display information.
The binary number system uses only two digits: 0 and 1. Each digit in a binary number is called a bit (short for binary digit). Since computers operate using two voltage levels (high and low), binary is the most fundamental number system in computing.
Groups of 8 bits form a byte, which is a basic unit of data storage in computers. Each bit in a binary number has a place value that is a power of 2, starting from the rightmost bit (least significant bit).
| Bit Position | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|
| Place Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
For example, the binary number 10110010 can be understood by adding the place values of bits set to 1:
1x128 + 0x64 + 1x32 + 1x16 + 0x8 + 0x4 + 1x2 + 0x1 = 128 + 32 + 16 + 2 = 178 (in decimal)
The decimal number system is the most familiar system, used in everyday counting and calculations. It has a base of 10, using digits from 0 to 9. Each digit's place value is a power of 10, starting from the rightmost digit.
For example, the decimal number 345 can be expanded as:
3x10² + 4x10¹ + 5x10⁰ = 300 + 40 + 5 = 345
Because humans are used to decimal, it is often the starting point for understanding other number systems.
The octal number system has a base of 8 and uses digits from 0 to 7. It was historically used in computing because it provides a more compact way to represent binary numbers. Each octal digit corresponds exactly to three binary digits (bits).
For example, the octal number 725 represents:
7x8² + 2x8¹ + 5x8⁰ = 7x64 + 2x8 + 5x1 = 448 + 16 + 5 = 469 (in decimal)
Octal is less common today but still useful in some programming and computing contexts.
The hexadecimal number system has a base of 16 and uses sixteen symbols: digits 0-9 and letters A-F, where A=10, B=11, ..., F=15. Hexadecimal is widely used in computing because it represents binary data compactly - each hex digit corresponds to exactly four binary digits (bits).
For example, the hexadecimal number 3F represents:
3x16¹ + 15x16⁰ = 48 + 15 = 63 (in decimal)
Hexadecimal is commonly used in memory addresses, color codes in web design (like #FF5733), and low-level programming.
Converting numbers from one system to another is essential in computer knowledge. There are two main methods:
Let's look at how to convert between decimal, binary, octal, and hexadecimal with clear steps.
graph TD A[Start with Decimal Number] --> B[Divide by 2 (for binary)] B --> C[Write down remainder] C --> D[Divide quotient by 2 again] D --> E{Is quotient 0?} E -- No --> B E -- Yes --> F[Write remainders in reverse order] F --> G[Binary Number obtained] G --> H[Group binary digits in 4 bits] H --> I[Convert each group to Hex digit] I --> J[Hexadecimal Number obtained]Number systems are not just theoretical concepts; they have practical uses in computing:
| Number System | Base (Radix) | Digits Used | Example Number | Common Use |
|---|---|---|---|---|
| Binary | 2 | 0,1 | 1011 | Data representation in computers |
| Decimal | 10 | 0-9 | 156 | Everyday counting |
| Octal | 8 | 0-7 | 725 | Legacy computing, compact binary |
| Hexadecimal | 16 | 0-9, A-F | 3F | Memory addresses, color codes |
Step 1: Divide 156 by 2.
156 / 2 = 78, remainder = 0
Step 2: Divide 78 by 2.
78 / 2 = 39, remainder = 0
Step 3: Divide 39 by 2.
39 / 2 = 19, remainder = 1
Step 4: Divide 19 by 2.
19 / 2 = 9, remainder = 1
Step 5: Divide 9 by 2.
9 / 2 = 4, remainder = 1
Step 6: Divide 4 by 2.
4 / 2 = 2, remainder = 0
Step 7: Divide 2 by 2.
2 / 2 = 1, remainder = 0
Step 8: Divide 1 by 2.
1 / 2 = 0, remainder = 1
Step 9: Write the remainders in reverse order:
1 0 0 1 1 1 0 0
Answer: The binary equivalent of decimal 156 is 10011100.
Step 1: Write the place values for each bit (from right to left):
Bits: 1 0 1 1 0 1
Place values: 32 16 8 4 2 1
Step 2: Multiply each bit by its place value:
1x32 + 0x16 + 1x8 + 1x4 + 0x2 + 1x1 = 32 + 0 + 8 + 4 + 0 + 1 = 45
Answer: The decimal equivalent of binary 101101 is 45.
Step 1: Identify the decimal values of hex digits:
3 = 3, F = 15
Step 2: Write place values (16^1 and 16^0):
3 x 16 + 15 x 1 = 48 + 15 = 63
Answer: The decimal equivalent of hexadecimal 3F is 63.
Step 1: Convert each octal digit to 3-bit binary:
Step 2: Combine the binary groups:
111 010 101
Answer: The binary equivalent of octal 725 is 111010101.
Step 1: Write the numbers aligned:
1011
+ 1101
Step 2: Add bit by bit from right to left:
Step 3: Write down the final carry:
Carry 1
Step 4: Final sum:
11000
Answer: 1011 + 1101 = 11000 in binary.
When to use: When converting between binary and octal or hexadecimal to avoid errors and speed up the process.
When to use: When interpreting or converting hexadecimal numbers to decimal or binary.
When to use: When converting decimal to binary, octal, or hexadecimal.
When to use: During quick calculations or when a calculator is not allowed.
When to use: When adding binary numbers to avoid common mistakes.
Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.
Go to practice →