Arithmetic overflow

The Arithmetic overflow (English arithmetic overflow ) or counter overflow (English counter overflow), is a term used in computer science. Such an overflow occurs when the result of a calculation for the valid number range is too large to be interpreted correctly.

In most cases, you will encounter the overflow in arithmetic with two's complement numbers. So it can happen that the addition of two numbers with the same sign a number sign is created with others. In this case the processor sets the overflow bit. With some processors and programming languages ​​, an overflow through a runtime error or exception handling (Exception) can be collected.

The overflow is always dependent on the number representation used. He is not to be confused with the carry (English Carry).

Examples

32-bit integer

The most frequently used on 32- bit processors integer data type Integer can in two's complement values ​​-231 = -2,147,483,648 to ( 231 ) -1 = 2,147,483,647 represent. If now count towards 2,147,483,647 (binary 01111111 11111111 11111111 11111111 ) one, is obtained as expected 2,147,483,648 but -2147483648 because the binary value 10000000 00000000 00000000 00000000 is interpreted as a negative number. Such overflow is also the reason for the year -2038 problem.

4-bit two's

In two's complement positive and negative numbers can be displayed, so that the subtraction can be attributed to the addition. There are three cases to consider:

  • Generalization

One must look at the last two unearned always, here and called. If these are not equal, then the result is incorrect, as a result of an overflow. In the addition of a positive and a negative number, this can never be the case.

  • Conclusion

In a 4-bit architecture, which uses the two's complement, for example, the decimal number 10 is not dual imaged.

Some processors can register an overflow through an overflow.

77073
de