Sunday, January 13, 2008

Long MAX in C++

Yesterday I wrote a program to print long max in C++. In 32 bit systems it prints a very small value [ Refer the program ). I am wonder if I want to store a long number which is the most appropriate data type in C++.

#include < stdlib.h>
#include < iostream>
#include < limits>

using namespace std;

int main(int argc, char** argv) {

// Print the long max value
// 64 bit machine this prints -> 9223372036854775807
// 32 bit machine this prints -> 2147483647
cout << "Max value for long : " << numeric_limits::max() << endl;

return (EXIT_SUCCESS);
}

No comments: