Two’s Complement


A two's-complement system is a system in which negative numbers are represented by the two's complement of the absolute value. This system is the most common method of representing signed integers on computers. It is implemented in most processors since the arithmetic operations can be performed in the same way as for the unsigned binary numbers. Similarly to the S-M system, two’s complement’s MSB corresponds to the sign of the number (“1” represents negative numbers and “0” represents positive numbers). However, it’s big advantage as opposed to the S-M system in that there is only one representation of “0”. Positive numbers are represented as regular binary numbers with the MSB equal to 0. On the other hand, negative numbers are represented by the two's complement of the representation of the absolute value. To do that, all of the bits are inverted, by the bitwise NOT operation and the value of 1 is added to them. The decimal value of the number represented in the 2’s complement system follows:

Example:
00000101 = +5
11111011 = -5