numeric_limts

来源:互联网 发布:svd求逆矩阵 python 编辑:程序博客网 时间:2024/06/07 03:06
用于取得某数据类型的特征: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;

}