Two’s complement is the method used by computers to represent integers in binary format. A binary number with an LMb (Left Most bit) of 1 is negative, while a binary number with an LMb of 0 is either a positive number, or 0. The method involves writing out the value in binary format and then inverting the binary value and adding 1.
Example 1:
If we wanted to write out the value of -27 using Two’s Complement, we would do the following:
Firstly, we convert the number to a positive number:
27
We then convert the number to binary:

This gives us:
00011011
We now invert the binary values:
11100100
Lastly, we add 1:
11100101
The above value is a representation of -27 in binary format, note that the LMb is a 1.
Example 2:
If we wanted to convert from a binary number in Two’s Notation back to its negative integer value, we would do the following. Lets use -27 as before.
Firstly, we invert the binary values:
11100101
00011010
We then add 1 to our binary values:
00011011
Lastly, we convert the binary value to an integer:

16 + 8 + 2 + 1 = 27
We convert the integer to a negative because of the LMb, which gives us:
-27

One thought on “Two’s Complement”