#include<iostream>
#include<limits>
#include<string>
using namespace std;
int main()
{
cout << boolalpha;
cout << "max(short):" << numeric_limits<short>::max() << endl;
cout << "max(int):" << numeric_limits<int>::max() << endl;
cout << "max(long):" << numeric_limits<long>::max() << endl;
cout << endl;
cout << "max(float):" << numeric_limits<float>::max() << endl;
cout << "max(double):" << numeric_limits<double>::max() << endl;
cout << "max(long douuble):" << numeric_limits<long double>::max() << endl;
cout << endl;
cout << "is_signed(char)" << numeric_limits<char>::is_signed << endl;
cout << endl;
cout << "is_specialized(string):" << numeric_limits<string>::is_specialized << endl;
getchar();
getchar();
#include<limits>
#include<string>
using namespace std;
int main()
{
cout << boolalpha;
cout << "max(short):" << numeric_limits<short>::max() << endl;
cout << "max(int):" << numeric_limits<int>::max() << endl;
cout << "max(long):" << numeric_limits<long>::max() << endl;
cout << endl;
cout << "max(float):" << numeric_limits<float>::max() << endl;
cout << "max(double):" << numeric_limits<double>::max() << endl;
cout << "max(long douuble):" << numeric_limits<long double>::max() << endl;
cout << endl;
cout << "is_signed(char)" << numeric_limits<char>::is_signed << endl;
cout << endl;
cout << "is_specialized(string):" << numeric_limits<string>::is_specialized << endl;
getchar();
getchar();
}
vs2013中的运行结果如下:
max(short):32767
max(int):2147483647
max(long):2147483647
max(float):3.40282e+038
max(double):1.79769e+308
max(long douuble):1.79769e+308
is_signed(char)true
is_specialized(string):false