What it is
A number does not fit into the memory slot reserved for it, and the program either crashes or silently gets a wrong value. The best-known case is the Ariane 5 rocket, lost in 1996 because of one such number.
How we use it
We validate input limits: amounts, quantities, field lengths. Tests for "too large" and "negative" values are a mandatory part of checking calculations and payments.
What it looks like
A program reserves a memory slot of a fixed size for every number. 16 bits hold values from about โ32,768 to 32,767; 32 bits go up to a little over two billion. If a calculation produces something larger, the number overflows. Then one of two things happens:
- the program crashes with an error, which is the better outcome;
- the number silently "wraps around" into something tiny or negative, and the calculation carries on with a wrong value.
The most expensive example
In 1996 the Ariane 5 rocket blew up 37 seconds into its first flight. Its guidance software had been taken from the previous rocket, and the new, faster rocket's velocity did not fit into a 16-bit slot. The loss ran to hundreds of millions of dollars.
Where it happens without rockets
- Amounts stored in kopecks or cents in an old database whose field was sized for a smaller turnover.
- Counters, such as page views or order numbers, that one day hit the limit of their type.
- Dates: in 2038 the 32-bit time used by older systems runs out.
- A negative quantity in a shopping cart that turns into a discount.
How we use it
We validate input limits: amounts, quantities, field lengths. Our automated tests for calculations and payments always include "zero", "negative" and "too large".