共用方式為


numeric_limits::max

傳回型別的最大有限值。

static Type max( ) throw( );

傳回值

型別的最大有限值。

備註

最大的限制值是型別的 int 和 FLT_MAX INT_MAX 型別的 float。 如果是, is_boundedtrue,則傳回值是有意義的。

範例

// numeric_limits_max.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>

using namespace std;

int main() {
   cout << "The maximum value for type float is:  "
        << numeric_limits<float>::max( )
        << endl;
   cout << "The maximum value for type double is:  "
        << numeric_limits<double>::max( )
        << endl;
   cout << "The maximum value for type int is:  "
        << numeric_limits<int>::max( )
        << endl;
   cout << "The maximum value for type short int is:  "
        << numeric_limits<short int>::max( )
        << endl;
}

Output

The maximum value for type float is:  3.40282e+038
The maximum value for type double is:  1.79769e+308
The maximum value for type int is:  2147483647
The maximum value for type short int is:  32767

需求

標題: <limits>

命名空間: std

請參閱

參考

strstreambuf Class