Resources | Subject Notes | Computer Science
This section covers the fundamental concepts of binary representation and demonstrates how to perform binary addition and subtraction.
The binary number system is a base-2 system, using only two digits: 0 and 1. Each position in a binary number represents a power of 2. For example, the binary number 1011 is equivalent to:
$$(1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) = 8 + 0 + 2 + 1 = 11_{10}$$
Understanding binary is crucial because computers store and process information using binary.
Binary addition follows similar rules to decimal addition, but with only two possible outcomes: 0 or 1. Here are the rules:
Example: Add the binary numbers 1011 and 0110.
$$ \begin{array}{@{}c@{\,}c@{}c@{}c@{}c} & & 1 & 0 & 1 & 1 \\ + & & 0 & 1 & 1 & 0 \\ \hline \end{array} $$
Starting from the rightmost column:
The final sum is 10001, which is equal to 21 in decimal.
Table: Binary Addition Example
Binary | Decimal |
---|---|
1011 | 11 |
0110 | 6 |
Binary subtraction involves subtracting one binary number from another. Similar to addition, the rules are:
To perform subtraction, we borrow from the next more significant bit. If the bit to be subtracted is 0 and the corresponding bit in the next position is also 0, we need to borrow from the next higher position.
Example: Subtract the binary numbers 1101 and 1010.
$$ \begin{array}{@{}c@{\,}c@{}c@{}c@{}c} & 1 & 1 & 0 & 1 \\ - & 1 & 0 & 1 & 0 \\ \hline \end{array} $$
Starting from the rightmost column:
The difference is 0111, which is equal to 7 in decimal.
Table: Binary Subtraction Example
Binary | Decimal |
---|---|
1101 | 13 |
1010 | 10 |
Binary addition and subtraction are fundamental operations in computer science. Understanding these concepts is essential for comprehending how computers manipulate data.