In digital systems, arithmetic operations such as addition and subtraction are essential for performing calculations. These operations are typically carried out using binary numbers, which are represented by combinations of 0s and 1s. To handle negative numbers and subtraction, a system known as 2’s complement is commonly used.
Binary addition is similar to decimal addition but is based on the binary number system (base 2). The rules for binary addition are:
| Bit 1 | Bit 2 | Sum (S) | Carry (C) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Let's add two binary numbers: 1011 (11 in decimal) and 1101 (13 in decimal).
1011 (11)
+ 1101 (13)
---------
11000 (24)
11000, which is 24 in decimal.Binary subtraction is done using the concept of borrowing, just like in decimal subtraction. However, binary subtraction uses the rules of binary arithmetic to handle borrowing.
The subtraction rules for binary are:
| Bit 1 | Bit 2 | Difference (D) | Borrow (B) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 (borrow) | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
Let's subtract 1101 (13 in decimal) from 1011 (11 in decimal).
1011 - 1101:
To subtract, we need to borrow from the next higher bit.
1011
- 1101
--------
1110 (Negative result)
But binary subtraction is more efficient when we use 2's complement to represent negative numbers. Let's now look at 2’s complement to handle negative numbers.
In binary arithmetic, the 2’s complement system is widely used to represent negative numbers. It allows the subtraction of numbers by simply adding their 2’s complement, avoiding the need for explicit subtraction.
To find the 2's complement of a binary number:
Let's find the 2's complement of 1011 (11 in decimal).
Invert all bits of 1011:
1011 becomes 0100.Add 1 to 0100:
0100 + 1 = 0101, which is 5 in decimal.Thus, the 2's complement of 1011 is 0101. The result represents -5 in decimal.
Subtraction can be easily done by converting the subtrahend (the number to be subtracted) to its 2’s complement and then adding it to the minuend (the number from which subtraction is being done).
Suppose you want to subtract 6 from 11 (i.e., 11 - 6).
Convert 6 to binary: 6 in binary is 0110.
Find the 2's complement of 6:
0110: 10011: 1001 + 1 = 1010, so the 2's complement of 6 is 1010.Add the 2's complement of 6 to 11:
11 in binary is 1011.6 (1010) to 1011: 1011
+ 1010
------
10101
Discard the carry bit: The final result is 0101, which is 5 in decimal, confirming that 11 - 6 = 5.
Single Representation for Zero: In 2's complement, there is only one way to represent zero, which avoids the issue of having two representations for zero (positive and negative) as in sign-magnitude representation.
Simpler Hardware Design: Arithmetic operations like addition and subtraction can be performed using the same hardware for both positive and negative numbers, simplifying circuit design.
Efficient Subtraction: Subtraction is handled by addition of 2's complement, which simplifies hardware design and avoids the need for a separate subtraction circuit.
Open this section to load past papers