Next: Mixed-Mode Arithmetic, 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 Conversion among Integer Types.
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.