Fill in the following tables with eight bit numbers Discuss
Solution
3 a)
3 b)
3 c)
Overflow rule : If two numbers with the same sign (both positive or both negative) are added, then overflow occurs if and only if the result has the opposite sign.
Overflow occurs when the number that you trying to represent is out of the range of numbers that can be represented. In your example you are using 4-bits two\'s complement, that means you can represent any number in the range -8 (1000) up to +7 (0111). The result of your subtraction 2-1 is +1, a number that lies within the range of representation.
When we add a negative and a positive operand, the result will always be in the range of representation. Overflows occur when we add two numbers with the same sign (both positive or both negative) and the result has the opposite sign.
Most of misunderstanding surrounding carry-out and overflow comes from the fact we use the carry-out as one of the parameters to generate overflow flag. They are strongly related but they are not the same thing.
When adding numbers in two\'s complement, if the carry-out and the carry-on into the most significant bit (sign bit) are different that means an overflow has occurred.
Let\'s see two negative operands with a positive result:
The carry-out is 1 and the carry-on to sign bit (MSB) is 0.
And now, an example of two positive operands with a negative result.
Underflows refer to floating point underflow, where an operation result in a number that is too small to be representable. For example, if the exponent part can represent values from 127127 to 127127, then any number with absolute value less than 21272127 may cause underflow.
If you go with two\'s complement addition, then it is as you say: carry of 1 is underflow.
4. Truth table for function which accepts two 2-bit numbers and returns one 3-bit sum
first operand = 2 binary - 10
second operand = 3 binary - 11
sum = 5 binary - 101
Hence, output is 101 i.e. 5
| Decimal | Signed Magnitude | 1s Complement | 2s complement | |
| -67 | 1 | 0111100 | 0111101 | |
| + | 42 | 0 | 0010101 | 0010110 |
| -25 | 1 | 0000110 | 0000111 |
