0
votes

If I have

0010 1101

0110 1111

____+

1001 1100

Is it overflow? because the sign of the first digit becomes 1 and 1 represents negative? I am very weak in binary.

What if you add

1111 1111

1111 1111

___+

1111 1110

with carryout 1 that is not an overflow? because 1111 1110 represents -2?

Thanks for helping!

2

2 Answers

0
votes

It depends on how you are treating your value - is it signed or unsigned. If it is unsigned binary, than it is not overflow. If it is signed one, than overflow did occure.

I guess we are talking about signed values, than basicly, overflow is when value change its sign due to binary arithmetic operation which result exceeds max-min range.

0
votes

If you are using a plain binary representation without sign, it is not an overflow

0010 1101->45
0110 1111->111

45+111 = 156. You can operate in the range [0, 255] then it is not an overflow.

If you are using the two's complement you have the range from -128 to 127, having only one representation of 0. Then it is an overflow because 156 is out of the range [-128, 127]

You can not just use the first bit to represent the sign because then you have 10000000 and 00000000 representing 0 and -0. The you should use two's complement to operate with negative numbers.