Binary Arithmetic Operation (Digital Logic Notes)
In mathematics, the four basic arithmetic operation applied on numbers are addition, subtraction, multiplication and division. In computers the same operation are performed inside the central processing unit by the arithmetic and logic unit (ALU). However, the arithmetic and logic unit cannot perform binary subtractions directly. It performs binary subtraction using a process known as complementation. For multiplication and division, the arithmetic and logic unit uses a method called shifting before adding the bits.
Binary Addition
The five possible addition in binary are:
1. 0 + 0 = 02. 0 + 1 = 13. 1 + 0 = 14. 1 + 1 = 10 (read as sum 0, carry 1)5. 1 + 1 = 11 (read as sum 1, carry 1)
Example : Find the sum of 111+001 base 2.
Solution :
Arrange the bits vertically :
Working from the right to the left, we proceed as follows: +011
Step 1: 1 + 1 = 10 (write down 0 and carry 1) 1010
Step 2: 1 + 1 + 1 = 11 (add and carry over digit to 1 + 1 in order to get 1 + 1 + 1. From the sum, write down digit one the carry forward)
Step 3: 1 + 1 + 0 = 10 (add the carry over digit to 1 + 0 in order to get 1 + 1 + 0. since this is the last step, write down 10).
Therefore 111 + 011 = 1010
This can be summarized in the table
Binary Subtraction
Direct Subtraction
The four possible subtraction in binary are:
1. 0 - 0 = 02. 1 - 0 = 13. 1 - 1 = 04. 10 - 1 = 1 (Borrow 1 from the next most significant digit to to make 0 become 10, hence 10 -1 = 1)
Complements
Complements are used in digital computers for simplifying the subtraction operation and for logical manipulation. There are two types of complements for each base-r system.
The radix complement and the diminished radix complement.
The first is referred to as the r's complement and the second as the (r-1)'s complement.
When the value of the base r is substituted in the name, the two types are referred to as the 2's complement and 1's complement for binary numbers, and the 10's complement and 9's complement and 1's complement for binary numbers, and the 10's complement and 9's complement for decimal numbers.
Also this, complement method reduce the hardware complexity of a system , as it uses same adder circuit for addition as well as subtraction.
(r-1)'s complement
- Number N in base r having n digit
- Complement of N is (r ^ n -1) -N
- 9's Complement for base 10
- Complement of 100 is (10^4 -1) -1000 = 8999
- Complement of 1234 is 9999 9999-1234 = 8765
- 1's Complement for base 2
- Complement of 1000 is (2^4 -1 ) -1000 = 0111
- Complement of 10110 is 11111 - 10110 = 01001
- Complement of 0 is (2^1 - 1) - 0 = 1
r's Complement
- Number N is base r having n digits
- Complement of N is r^n - N for n =/= 0, else 0
- 10's Complement for base 10
- Complement of 1000 is 10^4 - 1000 = 9000
- Complement of 1234 is 10000 - 1234 = 8766
- 2's Complement for base 2
- Complement of 1000 is 2^4 - 1000 = 1000
- Complement of 10110 is 100000 - 10110 = 01010
- Complement of 0 is 0
- Add 1 to (r - 1)'s complement value.
Example:
Subtract using 1's Complement and 2's Complement.
A. (100)2 - (1010)2
Solution :
For 1's Complement
1's Complement of (1010) = 0101
Adding it with 0100 = 0101
+ 0100
1001
Taking 1's Complement of result and placing '-ve' sign = -(0110)2
For 2's Complement,
2's Complement of 1010 = 0110
Adding with (0100) 0110
+0100
1010
Taking 2's Complement of result and placing '-ve ' sign. = - (0110)2
Comments
Post a Comment