Common Computer Science References
At the end of this lesson, you will be able to:
understand 2s compliment overflow
review 1s compliment
problem we have is that there are 2 0s!!
so here is something to notice: if we have 1 positive and 1 negative number, then there is actually no way to get an overflow (the number will always fit in our bits). If we have both negative or both positive numbers we can have an overflow (or underflow).Â
so the rule is: ONLY if both number are the same magnitude (ie. they both have 1s or both have 0s in the most significant digit), AND the most significant digit (the leftmost digit of the answer, not the carry out!) of the answer is different, is the flag set to 1 (some error, overflow or underflow).
that is because if both are 0s, that means we started with a positive number. If we end with a left bit of 1, that means the answer is negative. That would be impossible!
nil
complete worksheet