Professional Documents
Culture Documents
Program: BS(SE)
RegNo#: 12226
2’s complement
• 2’s complement number is formed by changing 1’s into 0’s and
0’s into 1’s then adding 1.
• 2’s complement of –1010
• +1010=01010
• The 1’s complement 10101
• 2’s complement add 1 to 1’s complement
• 10101+1=10110
• X=-9, Y=+5
Example:
• Find X+Y, Using 2’s complement
Y=0 0101
X=(100000-1)-00101+1=11111-01001+1
X=1 0110+1=1 0111
1 0111
0 0101
1 1100
2’s complement
In 2’s complement representation, we look at the first digit of the
binary number to determine if it is positive or negative. If the
number is position, the number will start with 0. If the number is
negative, the number will start with 1.
Example
Let’s convert 10110110.
Since the most significant bit is 1, we need to flip the digits in the
number.
10110110 → 01001001.
Add 1 to the number. 01001001+1=01001010.
01001010 (binary) = 74 (decimal).
So, 10110110 (2’s complement) =-74 (decimal).
The End