If you have given a decimal number, convert it into a binary number. Now you got the binary number.
Note: If you are C programmer, you can find this easiest program to convert decimal into binary in C.
Following are the methods you can use to find 2’s complement of any number.
Remember, For this method, it is necessary to know bit manipulation.
If you are not good at understanding binary bits, follow the simple trick given below.
It will be easy to demonstrate and to understand it by taking an example. Let’s find the 2’s complement of binary number 001100.
Follow the simple steps described in the image.
With this logic and bit manipulation, you can also write a program in C and Java to find the 2’s complement of the given number.
2’s complement of the number will be helpful in many bit operations. So do remember how to find 2’s complement of any number. In the upcoming article, I will write a note about the significance of 2’s complement and where it is useful.
Do you know any other method to find the 2’s complement of the number? If yes, please share with us in the comment.
I need help with my Python project…
Drop us an email at [email protected] . Our team will help you.