Two's complement question.
hi, so instead of just giving you the trick to 2s compliment, do you understand how or why the 2s compliment is constructed?
if it's positive, i just keep it the same. and if it's negative, i write the positive number, flip the bits, and add 1 right?
I got 9 for both.
is that right?
well 131 can be represented with just 8, but wouldn't the first number represent negative and postive?
for twos compliment notation, generally you add a single bit, but there is a special exception
or do we not need to worry about signed magnitude arch?
For example, for two bits we have: 00 = 0 01 = 1 10 = -2 11 = -1 Our range is -2 to 1, which is given by \(-2^{n-1}\) to \(2^{n-1}-1\).
So 8 bits will support -128 to 127
wait why is 10, -2?
do we just subtract 1 and flip the bits?
If you add \(1+-2\), we have \(01 + 10 = 11\) which is \(-1\).
It wraps around so that addition will still work.
Join our real-time social learning platform and learn together with your friends!