Namespaces
Variants

std::numeric_limits<T>:: max_exponent

From ja.cppreference.net
Utilities library
static const int max_exponent ;
(C++11まで)
static constexpr int max_exponent ;
(C++11以降)

std:: numeric_limits < T > :: max_exponent の値は、 n が r n-1
となる最大の正の数であり、ここで r は std:: numeric_limits < T > :: radix であり、浮動小数点型 T の有限の表現可能な値である。

標準特殊化

T std:: numeric_limits < T > :: max_exponent の値
/* non-specialized */ ​ 0 ​
bool ​ 0 ​
char ​ 0 ​
signed char ​ 0 ​
unsigned char ​ 0 ​
wchar_t ​ 0 ​
char8_t (C++20以降) ​ 0 ​
char16_t (C++11以降) ​ 0 ​
char32_t (C++11以降) ​ 0 ​
short ​ 0 ​
unsigned short ​ 0 ​
int ​ 0 ​
unsigned int ​ 0 ​
long ​ 0 ​
unsigned long ​ 0 ​
long long (C++11以降) ​ 0 ​
unsigned long long (C++11以降) ​ 0 ​
float FLT_MAX_EXP
double DBL_MAX_EXP
long double LDBL_MAX_EXP

例

max_exponent、 max_exponent10 および max() の関係を float 型について示します:

#include <iostream>
#include <limits>
int main()
{
    std::cout << "max() = " << std::numeric_limits<float>::max() << '\n'
              << "max_exponent10 = " << std::numeric_limits<float>::max_exponent10 << '\n'
              << std::hexfloat << '\n'
              << "max() = " << std::numeric_limits<float>::max() << '\n'
              << "max_exponent = " << std::numeric_limits<float>::max_exponent << '\n';
}

出力:

max() = 3.40282e+38
max_exponent10 = 38
max() = 0x1.fffffep+127
max_exponent = 128

関連項目

正規化浮動小数点値として有効な10の最小負のべき乗
(public static member constant)
正規化浮動小数点値として有効な基数の最小負のべき乗より1大きい値
(public static member constant)
有効な有限浮動小数点値である10の最大整数べき乗
(public static member constant)