What is 2’s Complement?
A two's-complement number system encodes positive and negative values in binary form. Except for the most important bit, whose weight is the inverse of the corresponding power of two, the weight of each bit is a power of two.
The signed binary integers are also represented by 2's complement. To determine the binary number's 2's complement, first, find the binary number's 1's complement and then add 1 to the least significant bit of it.
Uses of 2’s Complement
The representation of 2's complement is unambiguous, it is highly helpful in computer number representation. A positive number is simply expressed as a magnitude form. So there is nothing to be done to represent positive numbers. However, if we want to represent a negative integer, we must use either the 1's complement or the 2's complement approach.
The 2's complement of binary numbers is used in a variety of ways, most especially in signed binary number encoding and different mathematical operations for Binary numbers, such as additions and subtractions.
Addition using 2’s Complement
When we add two binary integers using 2's complement, we can get three different cases, which are as follows:
Case 1: Addition of a positive and a negative number when the positive number is greater in magnitude.
Find the 2's complement of the given negative number. Add the specified positive number to the result. If we receive an end-around carry 1, the number will be positive, the carry bit will be eliminated, and the remaining bits will be the final result.
Case 2: Addition of a positive and a negative number when the negative number is greater in magnitude.
Find the 2's complement of the given negative number. Add the specified positive number to the result. There is no end-around carry, and the remaining bits will be the final result. The resultant is a negative value.
Case 3: Addition of two negative numbers
Find the 2's complement of both the negative numbers. Add these 2’s complement numbers. If we receive an end-around carry 1, the carry bit will be added to LSB, and forgetting the final result, we will take the2's complement of the result. The resultant is a negative value.
Subtraction using 2’s Complement
The adding an end-around carry-bit occurs only in 1's complement arithmetic operations in 2's complement arithmetic operations. The procedure for subtracting two binary numbers using 2's complement is given below:
(Note: The subtrahend is the number that will be subtracted from another number, i.e., minuend.)
- Take the 2's complement of the subtrahend.
- Add with the minuend
- If the result of the preceding addition contains carry bit 1, it is discarded, and the result is a positive integer.
- If there is no carry bit 1, then take the result 2's complement, which will be negative.
|Important Topics for Gate Exam|
|Brittle Material||Capacitors in Parallel|
|Capacitors in Series||Carnot Cycle|
|Cement Test||Clamping Circuit|
|Clipping Circuit||CMOS Fabrication|
|CMOS Converter||Column Base|