In mathematics, the 2s complement is an operation in which the binary variables are involved. The twos complement is widely used in the computer (machine) language to encode and decode computer codes. It is especially used to determine the 2s complemen...
In mathematics, the 2s complement is an operation in which the binary variables are involved. The twos complement is widely used in the computer (machine) language to encode and decode computer codes.
It is especially used to determine the 2s complement of negative numbers. While one’s complement is available but it is only applicable for the positive numbers. In this article, we will discuss all the theory and examples of the twos complement.
In number system, the 2s complement is an operation that is frequently used to encode the negative and positive numbers in the form of binary variables. It is usually used in logic gates such as AND gate, NOT gate, OR gate, etc.
While the working of 1s complement is almost similar to twos complement but it is only applicable for the positive binary, decimal, & hexadecimal numbers. The reason of creating a new operation is just for the representation of the negative terms.
The 2s complement is a perfect example of true complement (radix complement). Twos complement can be evaluated by adding 1 to the least significant bit of the 1s complement. While the one’s complement is determined by taking the transpose of the binary numbers.
To turn the binary and decimal numbers system into two’s complement, follow the below procedure.
To transform the binary variables into 2s complement, keep an eye on the following steps.
Now you are able to transform any binary variable into 2s complement just by learning the above steps. A 2’s complement calculator can be used to get the result according to the above steps. Let us take a few examples to learn how to implement these steps manually.
Example - 1
Transform 110011001010 into twos complement.
Solution
Step - 1 : Firstly, take a number in the form of 0 & 1.
110011001010
Step - 2 : Invert all the binary variables such as transform all the 1s into 0s and all the 0s into 1s.
001100110101
Step - 3 : Add one to the LSB of the transpose of the binary variables to get the result in twos complement.
Therefore,
001100110110 is the twos complement of the given binary number.
Example - 2
Transform the given 16-bit binary number into twos complement.
0001110001110001
Solution
Step - 1 : Firstly, take a number in the form of 0 & 1.
0001110001110001
Step - 2 : Invert all the binary variables such as transform all the 1s into 0s and all the 0s into 1s.
0001110001110001
Step - 3 : Add one to the LSB of the transpose of the binary variables to get the result in twos complement.
Therefore,
0001110001110010 is the twos complement of the given binary number.
To transform the positive and negative decimal numbers into 2s complement, keep an eye on the following steps.
Now you are able to transform any positive or negative decimal numbers into 2s complement just by learning the above steps. Let us take a few examples to learn how to implement these steps manually.
Transform 478 into 2s complement.
Solution
Step - 1 : First of all, take the negative decimal number in the form of base 10.
478
Step - 2 : Now Transform the given positive base 10 number in the form of base 2 number.
Hence,
478 = (111010100)2
Step - 3 : Invert all the binary variables such as transform all the 1s into 0s and all the 0s into 1s.
111010100
Step - 4 : Add one to the LSB of the transpose of the binary variables to get the result in twos complement.
Therefore,
111010101 is the twos complement of the given positive decimal number.
Transform -718 into 2s complement.
Solution
Step - 1 : First of all, take the negative decimal number in the form of base 10.
-718
Let’s calculate the 2s complement of positive 718.
Step - 2 : Now Transform the given positive base 10 number in the form of base 2 number.
Hence,
718 = (1011001110)2
Step - 3 : Invert all the binary variables such as transform all the 1s into 0s and all the 0s into 1s.
0100110001
Step - 4 : Add one to the LSB of the transpose of the binary variables to get the result in twos complement.
Hence,
0100110010 is the 2s complement of 718.
Step - 5 : Now treat the 2s complement of 357 as a binary variable and apply the procedure of binary to 2s complement to determine the 2s complement of the negative decimal number.
1011001101
Step - 6 : Add one to the LSB of the transpose of the binary variables to get the result in twos complement.
Hence,
1011001110 is the 2s complement of - 718.
Now you can easily convert the base 2 number system and base 10 number system into 2s complement just by learning the steps discussed in the above post. You can get all the basics the two’ complement just by learning this post.
Tell us your learning requirements in detail and get immediate responses from qualified tutors and institutes near you.
Post Learning Requirement