Standard library header <limits>

From cppreference.com
< cpp‎ | header
 
 
Standard Library headers
Note: a slash '/' in a revision mark means that the header was deprecated and/or removed.
Language Support
Concepts
<concepts> (C++20)
Diagnostics
<system_error> (C++11)
General utilities
<bitset>
<tuple> (C++11)
<optional> (C++17)
<any> (C++17)
<variant> (C++17)
<type_traits> (C++11)
<ratio> (C++11)
<chrono> (C++11)
Strings
<charconv> (C++17)
<format> (C++20)

<cwchar>
<cuchar> (C++11)

Localization
<codecvt> (C++11/17)

Containers
<span> (C++20)
<array> (C++11)
<vector>
Iterators
<iterator>
Ranges
<ranges> (C++20)
Algorithms
<execution> (C++17)
Numerics
<bit> (C++20)
<numbers> (C++20)
<cfenv> (C++11)
<cmath>
Input/Output
<cstdio>
<cinttypes> (C++11)
<strstream> (C++98/)

Regular expressions
<regex> (C++11)
Filesystem support
<filesystem> (C++17)
Thread support
<thread> (C++11)
<atomic> (C++11)
<mutex> (C++11)
<shared_mutex> (C++14)
<condition_variable> (C++11)  
<future> (C++11)
<stop_token> (C++20)
<semaphore> (C++20)

<latch> (C++20)
<barrier> (C++20)

C compatibility
<cstdbool> (C++11/17/20)
<ccomplex> (C++11/17/20)
<ctgmath> (C++11/17/20)
<cstdalign> (C++11/17/20)
<ciso646> (until C++20)
<stdatomic.h>
 

This header is part of the type support library.

Declarations

provides an interface to query properties of all fundamental numeric types.
(class template)
indicates floating-point rounding modes
(enum)
indicates floating-point denormalization modes
(enum)

Synopsis

namespace std {
    template<class T> class numeric_limits;
 
    enum float_round_style {
        round_indeterminate         = -1,
        round_toward_zero           =  0,
        round_to_nearest            =  1,
        round_toward_infinity       =  2,
        round_toward_neg_infinity   =  3,
    };
 
    enum float_denorm_style {
        denorm_indeterminate = -1,
        denorm_absent        =  0,
        denorm_present       =  1
    };
 
 
    template<> class numeric_limits<bool>;
 
    template<> class numeric_limits<char>;
    template<> class numeric_limits<signed char>;
    template<> class numeric_limits<unsigned char>;
    template<> class numeric_limits<char8_t>;
    template<> class numeric_limits<char16_t>;
    template<> class numeric_limits<char32_t>;
    template<> class numeric_limits<wchar_t>;
 
    template<> class numeric_limits<short>;
    template<> class numeric_limits<int>;
    template<> class numeric_limits<long>;
    template<> class numeric_limits<long long>;
    template<> class numeric_limits<unsigned short>;
    template<> class numeric_limits<unsigned int>;
    template<> class numeric_limits<unsigned long>;
    template<> class numeric_limits<unsigned long long>;
 
    template<> class numeric_limits<float>;
    template<> class numeric_limits<double>;
    template<> class numeric_limits<long double>;
}


Class template std::numeric_limits

template<class T> class numeric_limits {
public:
    static constexpr bool is_specialized = false;
 
    static constexpr T min() noexcept { return T(); }
    static constexpr T max() noexcept { return T(); }
    static constexpr T lowest() noexcept { return T(); }
 
    static constexpr int digits = 0;
    static constexpr int digits10 = 0;
    static constexpr int max_digits10 = 0;
 
    static constexpr bool is_signed = false;
    static constexpr bool is_integer = false;
    static constexpr bool is_exact = false;
    static constexpr int radix = 0;
    static constexpr T epsilon() noexcept { return T(); }
    static constexpr T round_error() noexcept { return T(); }
 
    static constexpr int min_exponent = 0;
    static constexpr int min_exponent10 = 0;
    static constexpr int max_exponent = 0;
    static constexpr int max_exponent10 = 0;
 
    static constexpr bool has_infinity = false;
    static constexpr bool has_quiet_NaN = false;
    static constexpr bool has_signaling_NaN = false;
    static constexpr float_denorm_style has_denorm = denorm_absent;
    static constexpr bool has_denorm_loss = false;
    static constexpr T infinity() noexcept { return T(); }
    static constexpr T quiet_NaN() noexcept { return T(); }
    static constexpr T signaling_NaN() noexcept { return T(); }
    static constexpr T denorm_min() noexcept { return T(); }
 
    static constexpr bool is_iec559 = false;
    static constexpr bool is_bounded = false;
    static constexpr bool is_modulo = false;
 
    static constexpr bool traps = false;
    static constexpr bool tinyness_before = false;
    static constexpr float_round_style round_style = round_toward_zero;
 
};

Specialization std::numeric_limits<bool>

template<> class numeric_limits<bool> {
public:
    static constexpr bool is_specialized = true;
 
    static constexpr bool min() noexcept { return false; }
    static constexpr bool max() noexcept { return true; }
    static constexpr bool lowest() noexcept { return false; }
 
    static constexpr int digits = 1;
    static constexpr int digits10 = 0;
    static constexpr int max_digits10 = 0;
 
    static constexpr bool is_signed = false;
    static constexpr bool is_integer = true;
    static constexpr bool is_exact = true;
    static constexpr int radix = 2;
    static constexpr bool epsilon() noexcept { return 0; }
    static constexpr bool round_error() noexcept { return 0; }
 
    static constexpr int min_exponent = 0;
    static constexpr int min_exponent10 = 0;
    static constexpr int max_exponent = 0;
    static constexpr int max_exponent10 = 0;
 
    static constexpr bool has_infinity = false;
    static constexpr bool has_quiet_NaN = false;
    static constexpr bool has_signaling_NaN = false;
    static constexpr float_denorm_style has_denorm = denorm_absent;
    static constexpr bool has_denorm_loss = false;
    static constexpr bool infinity() noexcept { return 0; }
    static constexpr bool quiet_NaN() noexcept { return 0; }
    static constexpr bool signaling_NaN() noexcept { return 0; }
    static constexpr bool denorm_min() noexcept { return 0; }
 
    static constexpr bool is_iec559 = false;
    static constexpr bool is_bounded = true;
    static constexpr bool is_modulo = false;
 
    static constexpr bool traps = false;
    static constexpr bool tinyness_before = false;
    static constexpr float_round_style round_style = round_toward_zero;
 
};