#include <iostream>
#include <cstdlib>
#include <limits>
#include <string>
using namespace std;
int main()
{
//判断各类型有无极值
cout << boolalpha;
cout << "specialized(char): "
<< numeric_limits<char>::is_specialized
<< endl;
cout << "specialized(wchar_t): "
<< numeric_limits<wchar_t>::is_specialized
<< endl;
cout << "specialized(string): "
<< numeric_limits<string>::is_specialized
<< endl;
cout << noboolalpha << endl;
//各个类型的最大值
cout << "max(int): "
<< numeric_limits<int>::max()
<< endl;
cout << "max(short): "
<< numeric_limits<short>::max()
<< endl;
cout << "max(unsigned int): "
<< numeric_limits<unsigned int>::max()
<< endl;
cout << "max(unsigned short): "
<< numeric_limits<unsigned short>::max()
<< endl;
cout << "max(unsigned long): "
<< numeric_limits<unsigned long>::max()
<< endl;
cout << "max(long): "
<< numeric_limits<long>::max()
<< endl;
cout << "max(long long): "
<< numeric_limits<long long>::max()
<< endl;
cout << "max(float): "
<< numeric_limits<float>::max()
<< endl;
cout << "max(double): "
<< numeric_limits<double>::max()
<< endl;
cout << "max(long double): "
<< numeric_limits<long double>::max()
<< endl;
cout << endl;
//各个类型的最小值
cout << "min(int): "
<< numeric_limits<int>::min()
<< endl;
cout << "min(short): "
<< numeric_limits<short>::min()
<< endl;
cout << "min(unsigned int): "
<< numeric_limits<unsigned int>::min()
<< endl;
cout << "min(unsigned short): "
<< numeric_limits<unsigned short>::min()
<< endl;
cout << "min(unsigned long): "
<< numeric_limits<unsigned long>::min()
<< endl;
cout << "min(long): "
<< numeric_limits<long>::min()
<< endl;
cout << "min(long long): "
<< numeric_limits<long long>::min()
<< endl;
cout << "min(float): "
<< numeric_limits<float>::min()
<< endl;
cout << "min(double): "
<< numeric_limits<double>::min()
<< endl;
cout << "min(long double): "
<< numeric_limits<long double>::min()
<< endl;
system("pause");
return 0;
}
转载自http://blog.csdn.net/owl2008