Namespaces
Variants
Actions

Standard library header <limits>

From cppreference.com
< cpp‎ | header
 
 
Standard library headers
 

This header is part of the type support library.

Contents

[edit]Declarations

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

[edit]Synopsis

namespace std {enum float_round_style;enum float_denorm_style;   template<class T>class numeric_limits;   template<class T>class numeric_limits<const T>;template<class T>class numeric_limits<volatile T>;template<class T>class numeric_limits<constvolatile T>;   template<>class numeric_limits<bool>;   template<>class numeric_limits<char>;template<>class numeric_limits<signedchar>;template<>class numeric_limits<unsignedchar>;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<longlong>;template<>class numeric_limits<unsignedshort>;template<>class numeric_limits<unsignedint>;template<>class numeric_limits<unsignedlong>;template<>class numeric_limits<unsignedlonglong>;   template<>class numeric_limits<float>;template<>class numeric_limits<double>;template<>class numeric_limits<longdouble>;}

[edit]Enumeration std::float_round_style

namespace std {enum float_round_style { round_indeterminate =-1, round_toward_zero =0, round_to_nearest =1, round_toward_infinity =2, round_toward_neg_infinity =3, };}

[edit]Enumeration std::float_denorm_style

namespace std {enum float_denorm_style { denorm_indeterminate =-1, denorm_absent =0, denorm_present =1};}

[edit]Class template std::numeric_limits

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

[edit]Specialization std::numeric_limits<bool>

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

[edit]Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 184C++98 the definition of the specialization std::numeric_limits<bool> was not provided provided
LWG 559C++98 the std::numeric_limits specializations of cv-qualified
arithmetic types were missing in the synopsis
added
close