numeric_limits 获取基本类型的最大值或最小值

#include <iostream>
#include <limits>
#include <cstdlib>

using namespace std;

int main(int argc, char* argv[])
{
     int intMax = numeric_limits<int>::max();
     int intMin = numeric_limits<int>::min();

     float floatMax = numeric_limits<float>::max();
     float floatMin = numeric_limits<float>::min();

     cout << intMax << " " << intMin << endl;
     cout << floatMax << " " << floatMin << endl;

     system("pause");
     return 0;
}

你可能感兴趣的:(最值,numeric_limits)