c++c++11stlstandard-library

numeric_limits lowest and min member functions


numeric_limits<T>::min();
numeric_limits<T>::lowest();

What is the different between the value returned by both functions?


Solution

  • Paragraph 18.3.2.4 of the C++11 Standard specifies:

    static constexpr T min() noexcept;

    1 Minimum finite value.

    2 For floating types with denormalization, returns the minimum positive normalized value.

    3 Meaningful for all specializations

    [...]

    static constexpr T lowest() noexcept;

    6 A finite value x such that there is no other finite value y where y < x.

    7 Meaningful for all specializations in which is_bounded != false.

    Footnote 197 then adds the relevant remark:

    lowest() is necessary because not all floating-point representations have a smallest (most negative) value that is the negative of the largest (most positive) finite value.