32-bit ints only go to 2 billion. The unsigned int goes to 4 billion. Need to go higher? Microsoft's __int64 goes to 8 billion billion, and the unsigned version goes to 16 billion billion! Borland compilers use this, too. Try this:
cout << sizeof(unsigned int) << endl; // should be 4 bytes
cout << sizeof(unsigned __int64) << endl; // should be 8 bytes
unsigned __int64 a = 16;
for (int i = 0; i < 20; i++)
{
cout << a << endl; // tops out at 16 billion billion
a *= 10;
}
In GNU, it's "long long" and "unsigned long long":
cout << sizeof(unsigned int) << endl; // should be 4 bytes
cout << sizeof(unsigned long long) << endl; // should be 8 bytes
unsigned long long a = 16;
for (int i = 0; i < 20; i++)
{
cout << a << endl; // tops out at 16 billion billion
a *= 10;
}
If you want to write compiler independent code, use something like this:
#ifdef __GNUC__
#define ULONGINT unsigned long long
#endif
#ifdef _WIN32
#define ULONGINT unsigned __int64
#endif
#ifdef __BORLANDC__
#define ULONGINT unsigned __int64
#endif
cout << sizeof(ULONGINT) << endl; // should be 8 bytes
ULONGINT a = 16;
for (int i = 0; i < 20; i++)
{
cout << a << endl; // tops out at 16 billion billion
a *= 10;
}