Resources | Subject Notes | Computer Science
This section explores different number systems used to represent data in computers: decimal, binary, and hexadecimal. Understanding these systems is fundamental to understanding how computers store and process information.
The decimal system is the system we use in everyday life. It is a base-10 system, meaning it uses 10 digits (0-9) to represent numbers. Each position in a decimal number represents a power of 10.
For example, the number 123 can be broken down as: $1 \times 10^2 + 2 \times 10^1 + 3 \times 10^0 = 100 + 20 + 3 = 123$
The binary system is a base-2 system, meaning it only uses two digits: 0 and 1. Computers use binary to represent all data because electronic circuits can easily represent two states (on/off, high/low voltage), corresponding to 1 and 0.
Each position in a binary number represents a power of 2.
For example, the binary number 1011 is equal to: $1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 = 8 + 0 + 2 + 1 = 11$ (in decimal).
Position | Value |
---|---|
0 | $2^0 = 1$ |
1 | $2^1 = 2$ |
2 | $2^2 = 4$ |
3 | $2^3 = 8$ |
4 | $2^4 = 16$ |
5 | $2^5 = 32$ |
Conversion from decimal to binary: Divide the decimal number by 2, noting the remainder. The remainders, read in reverse order, give the binary equivalent.
Conversion from binary to decimal: Multiply each binary digit by the corresponding power of 2 and sum the results.
The hexadecimal system is a base-16 system. It uses 16 digits: 0-9 and A-F, where A=10, B=11, C=12, D=13, E=14, and F=15. Hexadecimal is often used to represent binary numbers in a more compact form.
Each position in a hexadecimal number represents a power of 16.
For example, the hexadecimal number 2A3 is equal to: $2 \times 16^2 + 10 \times 16^1 + 3 \times 16^0 = 2 \times 256 + 10 \times 16 + 3 \times 1 = 512 + 160 + 3 = 675$ (in decimal).
Position | Value |
---|---|
0 | $16^0 = 1$ |
1 | $16^1 = 16$ |
2 | $16^2 = 256$ |
3 | $16^3 = 4096$ |
Conversion from decimal to hexadecimal: Divide the decimal number by 16, noting the remainder. The remainders, read in reverse order, give the hexadecimal equivalent. Use A-F to represent values 10-15.
Conversion from hexadecimal to decimal: Multiply each hexadecimal digit by the corresponding power of 16 and sum the results.
Number System | Example | Decimal Equivalent |
---|---|---|
Binary | 1010 | 10 |
Decimal | 255 | 255 |
Hexadecimal | FF | 255 |