The limits of long type integers defined in the limits.h standard library header file are different in 32-bit and 64-bit modes, as shown in the following table.
Symbolic constant | Mode | Value | Hexadecimal | Decimal |
---|---|---|---|---|
LONG_MIN (smallest signed long) | 32-bit | -(231) | 0x80000000L | -2,147,483,648 |
64-bit | -(263) | 0x8000000000000000L | -9,223,372,036,854,775,808 | |
LONG_MAX (longest signed long) | 32-bit | 231-1 | 0x7FFFFFFFL | +2,147,483,647 |
64-bit | 263-1 | 0x7FFFFFFFFFFFFFFFL | +9,223,372,036,854,775,807 | |
ULONG_MAX (longest unsigned long) | 32-bit | 232-1 | 0xFFFFFFFFUL | +4,294,967,295 |
64-bit | 264-1 | 0xFFFFFFFFFFFFFFFFUL | +18,446,744,073,709,551,615 |
Implications of these differences are:
In situations where a long-type value can overflow when assigned to other variables or passed to functions, you must: