Limitation of my c++ program? How would I find this out?

Size limitations are particularly evident with integers. On some computers, integers can only be about 32,000, on others, they can go up to a little more than 2,000,000,000. What is the largest value your compiler will accept for a signed integer? What is the most negative allowed value?

How exactly would I find this out?
I'm not very sure about this topic, but...
Well, try starting with a large number and see how large it could get. Try using something like 10.000.000.000, if it accepts it then go up to 13.000.000.000, if it doesn't, try something like 8.000.000.000. Then start searching for billion max. values, then million max. values, then with thousands, hundreds and finally get the exact maximum number you can use for your computer. Same with negative numbers, i think.
Maybe this[1] might help(Note: on 32-bit systems).

References.
[1]http://cplusplus.com/doc/tutorial/variables/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <limits>

template <class T>
void show_max( const char* s )
{
    std::cout << "Max value for " << s << " is: " << std::numeric_limits<T>::max() << '\n' ;
}


int main()
{
    show_max<short>("short") ;
    show_max<int>("int") ;
    show_max<long>("long") ;
    show_max<long long>("long long") ;
    show_max<unsigned short>("unsigned short") ;
    show_max<unsigned>("unsigned") ;
    show_max<unsigned long>("unsigned long") ;
    show_max<unsigned long long>("unsigned long long") ;
}
Topic archived. No new replies allowed.