Computer Number Systems
A number system is a method of representing numbers using a set of digits and rules. Different number systems use different bases, also called radices. Computers use binary to represent and process data, while people commonly use decimal in everyday life.
This note explains the binary, decimal, octal, and hexadecimal number systems, their digits and bases, and how the same value can be represented in different systems.
What Is a Number System?
A number system is a way of writing numbers using a defined set of symbols and rules. The base (or radix) tells us how many distinct digits are used.
Most number systems used in computing are positional. In a positional number system, the value of a digit depends on both the digit and its position. For whole numbers, positions are based on powers of the system's base.
Binary Number System
The binary number system is a base-2 number system. It uses only two digits: 0 and 1. Each binary digit is called a bit (short for binary digit).
Computers use binary because digital electronic circuits can represent two states, commonly interpreted as 0 and 1. Binary data is used to represent instructions and many types of information.
For a whole-number binary value, each position represents a power of 2, starting from (2^0) at the right.
Example: Understanding 1011โ| Digit | 1 | 0 | 1 | 1 |
|---|---|---|---|---|
| Position value | 2ยณ | 2ยฒ | 2ยน | 2โฐ |
| Calculation | 1 ร 8 | 0 ร 4 | 1 ร 2 | 1 ร 1 |
Adding the results gives (8 + 0 + 2 + 1 = 11). Therefore, 1011โ represents decimal 11โโ.
Long binary values can be difficult for people to read. Octal and hexadecimal provide more compact ways of writing binary values.
Decimal Number System
The decimal number system is a base-10 number system. It uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. It is the number system most commonly used in everyday life.
Each position in a whole-number decimal value represents a power of 10, starting from (10^0) on the right.
Example: Understanding 457โโThe number 457โโ means:
- (4 \times 10^2 = 400)
- (5 \times 10^1 = 50)
- (7 \times 10^0 = 7)
Therefore, (400 + 50 + 7 = 457).
Octal Number System
The octal number system is a base-8 number system. It uses eight digits: 0, 1, 2, 3, 4, 5, 6, 7. The digits 8 and 9 are not valid octal digits.
Each position in an octal number represents a power of 8. Octal is useful in computing because each octal digit corresponds to a group of three binary bits, allowing some binary values to be written more compactly.
Example: Understanding 276โThe octal number 276โ can be expanded as:
- (2 \times 8^2 = 128)
- (7 \times 8^1 = 56)
- (6 \times 8^0 = 6)
Therefore, 276โ is equal to (128 + 56 + 6 = 190โโ).
To convert binary to octal, group the binary digits into sets of three, starting from the right. Add leading zeros to the left if needed, then replace each group with its corresponding octal digit.
Hexadecimal Number System
The hexadecimal number system is a base-16 number system. It uses sixteen symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
The letters represent decimal values from 10 to 15.
| Hexadecimal digit | Decimal value |
|---|---|
| A | 10 |
| B | 11 |
| C | 12 |
| D | 13 |
| E | 14 |
| F | 15 |
Each position in a hexadecimal number represents a power of 16. Hexadecimal is widely used in computing because one hexadecimal digit represents exactly four binary bits. It is a compact way to write binary values, including memory addresses and colour codes.
Example: Understanding 2FโโThe hexadecimal number 2Fโโ means:
2 ร 16ยน = 32F ร 16โฐ = 15
Therefore, 2Fโโ is equal to (32 + 15 = 47โโ). Remember that F represents 15 in hexadecimal.
Comparison of Number Systems
| Number system | Base (radix) | Digits used | Example |
|---|---|---|---|
| Binary | 2 | 0, 1 | 1011โ |
| Decimal | 10 | 0โ9 | 25โโ |
| Octal | 8 | 0โ7 | 276โ |
| Hexadecimal | 16 | 0โ9 and AโF | 2Fโโ |
The base determines the place values in each system. For example, the rightmost position of a whole number represents (2^0) in binary, (10^0) in decimal, (8^0) in octal, and (16^0) in hexadecimal.
Relationship Between Number Systems
The same numerical value can be represented in different number systems. The digits may look different, but the value remains the same when converted correctly.
Example: Representing decimal 25 in different systems| Number system | Representation of decimal 25 |
|---|---|
| Binary | 11001โ |
| Decimal | 25โโ |
| Octal | 31โ |
| Hexadecimal | 19โโ |
The small subscript indicates the base and helps avoid confusion when different systems use similar-looking digits.
Converting Between Binary and Octal
Since (8 = 2^3), one octal digit corresponds to three binary bits. For example:
11001โ โ 011 001 โ 31โ
The leftmost group is padded with a zero so that each group contains three bits. Then 011โ becomes 3โ and 001โ becomes 1โ.
Converting Between Binary and Hexadecimal
Since (16 = 2^4), one hexadecimal digit corresponds to four binary bits. For example:
11001โ โ 0001 1001 โ 19โโ
The binary value is padded on the left to make groups of four bits. The groups 0001โ and 1001โ correspond to hexadecimal digits 1 and 9.
Binary Code and Data Processing
Computers process data using binary representations. Text, numbers, images, and sound must be encoded into forms that a computer can store and process.
A character encoding system such as ASCII assigns a numeric code to each supported character. That code can then be represented in binary.
Example: Storing and Displaying the Letter AIn ASCII, the uppercase letter A has the decimal code 65. Its 8-bit binary representation is 01000001.
The CPU processes binary instructions and data. Data may be held temporarily in memory or saved in storage devices. When a program needs to display a character, the computer interprets the stored code according to the relevant encoding system.
Exam-Focused Points
Key Idea: The base (radix) of a number system is the number of distinct digits or symbols used in that system.
Key Idea: Binary uses base 2 and the digits 0 and 1. A single binary digit is called a bit.
Key Idea: The same value can be represented in different number systems. For example, decimal 25โโ is 11001โ, 31โ, and 19โโ.
When answering examination questions, check the base of each number carefully. A digit that is valid in one number system may not be valid in another. For example, 8 is valid in decimal but not in binary or octal.
Summary
A number system represents values using a defined set of digits and a base. The binary system uses 0 and 1 and is used by computers to represent data. The decimal system uses digits 0โ9 and is common in everyday calculations. The octal system uses digits 0โ7, while the hexadecimal system uses digits 0โ9 and AโF. These systems can represent the same value in different ways, and conversions help people work with the binary data used by computers.