Sunday, 21 October 2012

2’s Complement Number by (by amirul firuz)

We use of 2’s complement number because in microprocessor-base equipment, binary cannot do a minus operation. The equation need to be change from minus to plus ( a-b = a+(-b) ).

As an example, 
10 – 5

in binary 10 = 10102, while 5 = 1012
10102 - 1012

change it into this operation 10 + (-5),
**(remember!! -5 ≠ -1012 !!!)

to get -5 in binary, change 1 with 0, 0 with 1,
1012  0102                **(1st complement)
then add 1,
0102 + 12 = 0112     **(2nd complement)

thus, (-5) = 112

10 + (-5)  =  10102 + 112  =  11012  =  1012  (*ignore the overflow)

Now you completed the 2 complement section!



No comments:

Post a Comment