Next: Mixed Mode, Previous: Integer Arithmetic, Up: Arithmetic [Contents][Index]

When the mathematical value of an arithmetic operation doesn’t fit in
the range of the data type in use, that’s called *overflow*.
When it happens in integer arithmetic, it is *integer overflow*.

Integer overflow happens only in arithmetic operations. Type conversion operations, by definition, do not cause overflow, not even when the result can’t fit in its new type. See Integer Conversion.

Signed numbers use two’s-complement representation, in which the most
negative number lacks a positive counterpart (see Integers in Depth). Thus, the unary ‘`-`’ operator on a signed integer can
overflow.

• Unsigned Overflow | Overflow in unsigned integer arithmetic. | |

• Signed Overflow | Overflow in signed integer arithmetic. |