numeric_limits::max

型の最大の有限の値を返します。

static Type max( ) throw( );

戻り値

型の最大の有限の値。

解説

最大の有限な値は型 **[float]**の型 int と FLT_MAX の INT_MAX です。戻り値がの場合は 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;
}

出力

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