Learning Objectives
By the end of this lesson you will be able to:
- State the exact limits of Int32 and Int64 (and why they are those values)
- Identify which data type a field likely uses based on its context
- Select input values that probe the exact limits of each type
Why These Numbers?
A 32-bit integer stores its value in 32 binary digits (bits). One bit is reserved for the sign (positive/negative), leaving 31 bits for the magnitude.
2^31 = 2,147,483,648. Therefore:
- Int32 maximum: 2,147,483,647 (2^31 - 1)
- Int32 minimum: -2,147,483,648 (-2^31)
A 64-bit integer (Long in Java, int64 in most languages):
- Int64 maximum: 9,223,372,036,854,775,807 (2^63 - 1) — about 9.2 quintillion
- Int64 minimum: -9,223,372,036,854,775,808 (-2^63)
These are not arbitrary. They are the direct mathematical consequence of the bit width.
The Critical Test Values
Memorize these numbers. They are your testing toolkit for numeric fields:
| Type | Limit | Value |
|---|---|---|
| Int32 max | 2,147,483,647 | Test: 2147483647, 2147483648 |
| Int32 min | -2,147,483,648 | Test: -2147483648, -2147483649 |
| Int64 max | 9,223,372,036,854,775,807 | Test: 9223372036854775807 |
| Int64 min | -9,223,372,036,854,775,808 | Test: -9223372036854775808 |
The boundary tests are: the exact limit value and the limit value plus/minus one.
How to Know Which Type a Field Uses
You often can't know for certain without asking the developer. But you can infer:
- ID fields: Usually Int32 or Int64 (sequential IDs often exceed Int32 for large systems)
- Age, quantity, count: Typically Int16 or Int32 (small ranges)
- Financial amounts: Depends heavily — could be Int64, BigDecimal, or Long
- User counts / view counts: Int64 for anything at scale
- Legacy systems: Beware of Int16 (max 32,767) for fields that might grow
Pro Tip: Ask your developer: "What data type stores this field in the database, and what type is used in the application code?" The answer tells you exactly what to test.
The Hidden Danger: Mixed Types
A bug class more subtle than overflow: when the frontend uses a JavaScript number (64-bit float, safe up to 2^53 = about 9 quadrillion) but the backend uses Int32.
JavaScript sends a valid number. The backend can't store it. The result is a truncation, a conversion error, or a crash — depending on how the developer handles the mismatch.
Key Takeaways
- Int32 max is 2,147,483,647; Int64 max is 9,223,372,036,854,775,807
- These limits come from the mathematical consequence of fixed bit-width binary storage
- Test: exact limit, limit+1, and limit-1 for the most important boundaries
- Ask about actual data types — infer when you can't ask