Two's Complement
Page 1 of 2
Two’s Complement
Two’s complement is a mathematical operation way of storing integer using only ‘1’ and ‘0’. In order to differentiate between a positive and negative integer, all we have to do is take whatever binary number a integer is for that particular bit and just flip the ‘1’ to ‘0’ and vice versa then add one to that binary number. Therefore, a positive integer will always start with ‘0’ while a negative integer will always start with ‘1’
For example:
12 in 8bit is 00001100
So -12 will be 11110011
+ 1
=11110100
And to add two numbers just simply add the ‘1’ and ‘0’ while moving the 1 to the previous number.
Example:
5 =00000101
+
10 =00001010
15