std::numeric_limits
Defined in header <limits>
|
||
template< class T > class numeric_limits; |
||
The std::numeric_limits
class template provides a standardized way to query various properties of arithmetic types (e.g. the largest possible value for type int is std::numeric_limits<int>::max()).
This information is provided via specializations of the std::numeric_limits
template. The standard library makes available specializations for all arithmetic types (only lists the specializations for cv-unqualified arithmetic types):
Defined in header <limits>
|
||
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<wchar_t>; |
||
template<> class numeric_limits<char8_t>; |
(since C++20) | |
template<> class numeric_limits<char16_t>; |
(since C++11) | |
template<> class numeric_limits<char32_t>; |
(since C++11) | |
template<> class numeric_limits<short>; |
||
template<> class numeric_limits<unsigned short>; |
||
template<> class numeric_limits<int>; |
||
template<> class numeric_limits<unsigned int>; |
||
template<> class numeric_limits<long>; |
||
template<> class numeric_limits<unsigned long>; |
||
template<> class numeric_limits<long long>; |
(since C++11) | |
template<> class numeric_limits<unsigned long long>; |
(since C++11) | |
template<> class numeric_limits<float>; |
||
template<> class numeric_limits<double>; |
||
template<> class numeric_limits<long double>; |
||
The value of each member of a specialization of std::numeric_limits
on a cv-qualified type cv T
is equal to the value of the corresponding member of the specialization on the unqualified type T
. For example, std::numeric_limits<int>::digits is equal to std::numeric_limits<const int>::digits.
Aliases of arithmetic types (such as std::size_t or std::streamsize) may also be examined with the std::numeric_limits
type traits.
Non-arithmetic standard types, such as std::complex<T> or std::nullptr_t, do not have specializations.
If the implementation defines any integer-class types, specializations of |
(since C++20) |
Implementations may provide specializations of std::numeric_limits
for implementation-specific types: e.g. GCC provides std::numeric_limits<__int128>
. Non-standard libraries may add specializations for library-provided types, e.g. OpenEXR provides std::numeric_limits<half>
for a 16-bit floating-point type.
Contents |
[edit] Template parameters
T | - | a type to retrieve numeric properties for |
[edit] Member constants
[static] |
identifies types for which std::numeric_limits is specialized (public static member constant) |
[static] |
identifies signed types (public static member constant) |
[static] |
identifies integer types (public static member constant) |
[static] |
identifies exact types (public static member constant) |
[static] |
identifies floating-point types that can represent the special value "positive infinity" (public static member constant) |
[static] |
identifies floating-point types that can represent the special value "quiet not-a-number" (NaN) (public static member constant) |
[static] |
identifies floating-point types that can represent the special value "signaling not-a-number" (NaN) (public static member constant) |
[static] |
identifies the denormalization style used by the floating-point type (public static member constant) |
[static] |
identifies the floating-point types that detect loss of precision as denormalization loss rather than inexact result (public static member constant) |
[static] |
identifies the rounding style used by the type (public static member constant) |
[static] |
identifies the IEC 559/IEEE 754 floating-point types (public static member constant) |
[static] |
identifies types that represent a finite set of values (public static member constant) |
[static] |
identifies types that handle overflows with modulo arithmetic (public static member constant) |
[static] |
number of radix digits that can be represented without change (public static member constant) |
[static] |
number of decimal digits that can be represented without change (public static member constant) |
[static] (C++11) |
number of decimal digits necessary to differentiate all values of this type (public static member constant) |
[static] |
the radix or integer base used by the representation of the given type (public static member constant) |
[static] |
one more than the smallest negative power of the radix that is a valid normalized floating-point value (public static member constant) |
[static] |
the smallest negative power of ten that is a valid normalized floating-point value (public static member constant) |
[static] |
one more than the largest integer power of the radix that is a valid finite floating-point value (public static member constant) |