numeric_limts

用于取得某数据类型的特征:numeric_limits<T>

#include <iostream>

#include <limits>

#include <string>

 

using namespace std;

 

int main()

{

       cout << boolalpha;

 

       //看函数名字就知道了。

       cout << "max(short):" << std::numeric_limits<short>::max() <<endl;

       cout << "max(int):" << numeric_limits<int>::max() <<endl;

       cout << "max(long):" << numeric_limits<long>::max() <<endl;

 

       cout << "min(float):" << numeric_limits<float>::min() <<endl;

       cout << "max(double):" << numeric_limits<double>::max() <<endl;

       cout << "max(long double):" << numeric_limits<long double>::max() <<endl;

 

       cout << "is_signed(char):" << numeric_limits<char>::is_signed << endl;

       cout << "is_specialized(string)" << numeric_limits<string>::is_specialized << endl;

 

       return 0;

}

你可能感兴趣的:(numeric_limts)