**One’s complement:** It is method in binary system to denote negative values. In this system, to denote negative values 0’s are changed to 1’s and 1’s are changed to 0’s. By this method -10 will be denoted as: 10 in binary is 1010. To denote -10, by changing 0’s to 1’s and 1’s to zeros, we get 0101. Hence, by this method -10 will be denoted as 0101. This method is not used in Java.

**Two’s complement:** It is a method used in Java and many other programming languages to store negative integer values. In this process, negative numbers in binary are denoted by:

1) Change 0’s to 1’s and 1’s to 0’s

2) Add 1 to the above result.

For Example: 10 in binary is 1010. To denote -10 , by changing 0’s to 1’s and 1’s to zeros, we get 0101. And then after adding 1, we get 0110. Thus, by 2’s complement method, -10 is represented as 0110.

## Leave a Reply