It's about 2.1 * 10^9
. No need to know the exact 2^{31} - 1 = 2,147,483,647
.
C
You can find it in C like that:
#include <stdio.h>
#include <limits.h>
main() {
printf("max int:\t\t%i\n", INT_MAX);
printf("max unsigned int:\t%u\n", UINT_MAX);
}
gives (well, without the ,
)
max int: 2,147,483,647
max unsigned int: 4,294,967,295
C++ 11
std::cout << std::numeric_limits<int>::max() << "\n";
std::cout << std::numeric_limits<unsigned int>::max() << "\n";
Java
You can get this with Java, too:
System.out.println(Integer.MAX_VALUE);
But keep in mind that Java integers are always signed.
Python 2
Python has arbitrary precision integers. But in Python 2, they are mapped to C integers. So you can do this:
import sys
sys.maxint
>>> 2147483647
sys.maxint + 1
>>> 2147483648L
So Python switches to long
when the integer gets bigger than 2^31 -1