• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <limits>

    std::numeric_limits::round_error

    // C++03
    static const T round_error() throw();
    
    // C++11
    static constexpr T round_error() noexcept;
    

    概要

    最大の丸め誤差を取得する

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

    出力例

    0.5
    0.5