Note:
To calculate the 2's complement of an integer, invert the binary equivalent of the number by changing all of the ones to zeroes and all of the zeroes to ones (also called 1's complement), and then add one.
For example,
0001 0001(binary 17) ==> such that 1110 1111(two's complement -17)
1. NOT(0001 0001) = 1110 1110 (Invert bits)
2. 1110 1110 + 0000 0001 = 1110 1111 (Add 1)
No comments:
Post a Comment