Resources | Subject Notes | Computer Science
This section covers the conversion of numbers between the decimal (base-10) and binary (base-2) systems. Understanding these conversions is fundamental to understanding how computers store and process information.
Converting a decimal number to binary involves repeatedly dividing the decimal number by 2 and noting the remainders. The remainders, read in reverse order, form the binary equivalent.
Here's a step-by-step process:
Example: Convert the decimal number 25 to binary.
Division | Quotient | Remainder |
---|---|---|
$25 \div 2$ | $12$ | $1$ |
$12 \div 2$ | $6$ | $0$ |
$6 \div 2$ | $3$ | $0$ |
$3 \div 2$ | $1$ | $1$ |
$1 \div 2$ | $0$ | $1$ |
Reading the remainders in reverse order gives the binary equivalent: 11001.
Therefore, the decimal number 25 is equal to the binary number 11001.
Converting a binary number to decimal involves multiplying each binary digit by 2 raised to the power of its position (starting from the rightmost digit as position 0) and then summing the results.
Here's the process:
Example: Convert the binary number 11001 to decimal.
Binary Digit | Position | $2^{\text{Position}}$ | Product |
---|---|---|---|
1 | 4 | $2^4 = 16$ | $1 \times 16 = 16$ |
0 | 3 | $2^3 = 8$ | $0 \times 8 = 0$ |
0 | 2 | $2^2 = 4$ | $0 \times 4 = 0$ |
1 | 1 | $2^1 = 2$ | $1 \times 2 = 2$ |
1 | 0 | $2^0 = 1$ | $1 \times 1 = 1$ |
Summing the products: $16 + 0 + 0 + 2 + 1 = 19$.
Therefore, the binary number 11001 is equal to the decimal number 19.
The conversion between decimal and binary is a fundamental skill in computer science. Understanding these conversions is crucial for comprehending how data is represented and manipulated within a computer.