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
thus, (-5) = 112
10 + (-5) = 10102 + 112 = 11012 = 1012 (*ignore the overflow)
Now you completed the 2 complement section!
Now you completed the 2 complement section!
No comments:
Post a Comment