NUMBER SYSTEM
2's Complement
2's complement representation allows the use of binary arithmetic operation on signed integers , yielding the correct 2's complement results .
As with 1's complement, the most significant bit is used to indicate the sign (0 = positive, 1 = negative), and positive numbers are represented in the same way. To negate a positive number, its 2's complement is used .
Example :
3810 = 1001102
There are two steps to negate the binary number . First step , assume the bits to 8-bits . Second step , 1's complement . Third step is , 2's complement .
1001102 => 001001102 ( the leftmost bit is called sign bits )
For 1's complement , invert the binary number (flip it) . Invert 0 to 1 and 1 to 0 .
001001102 => 110110012 ( The sign bits shows 1 = negative )
For 2's complement , add +1 to the 1's complement number .
110110012
+ 000000012
___________________
110110102 (2's complement Number)
= -3810
Example :
4310 - 2210 = ?
4310 = 1010112 => 001010112
-2210 = 101102 => 000101102
=> 111010012 (flip the bits)
=> 111010102 (add +1 / 2's complement)
001010112
+ 111010102
_____________________
1000101012
= 2110
Post by :
IkhmalYazid
B031210153 > BITC S1G2
= -3810
Example :
4310 - 2210 = ?
4310 = 1010112 => 001010112
-2210 = 101102 => 000101102
=> 111010012 (flip the bits)
=> 111010102 (add +1 / 2's complement)
001010112
+ 111010102
_____________________
= 2110
Post by :
IkhmalYazid
No comments:
Post a Comment