• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    variable
    <limits>

    std::numeric_limits::max_exponent10

    // C++03
    static const int max_exponent10;
    
    // C++11
    static constexpr int max_exponent10;
    

    概要

    浮動小数点数型において、型Tの指数上限値を得る。
    基数10をmax_exponentの値で累乗した値が、型Tで表現可能な正規化された値となる最大の正の値。
    浮動小数点数型以外は0になる。

    対応するマクロを次の表に挙げる。

    対応するマクロ
    float FLT_MAX_10_EXP
    double DBL_MAX_10_EXP
    long double LDBL_MAX_10_EXP

    #include <iostream>
    #include <limits>
    
    int main()
    {
      constexpr int f = std::numeric_limits<float>::max_exponent10;
      constexpr int d = std::numeric_limits<double>::max_exponent10;
    
      std::cout << "float : " << f << std::endl;
      std::cout << "double : " << d << std::endl;
    }
    

    出力例

    float : 38
    double : 308
    

    参照