Integer Limits & Memory Overflows
A 32-bit integer can hold numbers from −2,147,483,648 to 2,147,483,647. That's about 2.1 billion. Seems like plenty — until someone asks your application to calculate a factorial for the number 15 (which is 1,307,674,368,000) or process a transaction amount in a country with high inflation.
When a number exceeds its container, something has to give. Sometimes it throws an exception. Sometimes it silently wraps around to a negative number. Either way, the calculation is wrong.
Why This Matters to Testers
Overflow bugs are insidious because they don't usually show up at normal values. They require specific knowledge of data type limits and deliberate testing at or beyond those limits.
The classic symptoms:
- A calculation result that is impossibly negative (overflow wrapped around)
- An application error at a seemingly random large number
- Correct behavior for small numbers, silent failure for large ones
What You'll Learn
- The exact limits of Int32 (±2.1B) and Int64 (±9.2 quintillion) and why they exist
- What integer overflow looks like from a user's perspective
- How to use factorial as a "overflow stress test" — factorials grow explosively fast
- How to test everyday calculator applications for overflow conditions
Your Practice Challenges
BigInt Factorial: Enter numbers designed to trigger Int32 overflow, then Int64 overflow. Watch what happens.
Calculator: Add numbers together until the result exceeds the Int32 boundary. The calculator should either handle this gracefully or reveal a bug — you're there to find out which.