`<limits>`

Include the standard header ** <limits>**
to define the template class

`numeric_limits`

.
Explicit specializations of this class describe many arithmetic properties
of the scalar types (other than pointers).Beginning with **C++11**,
all static const objects and static functions declared in this header
use `constexpr`

to signal that they are treated as
compile-time constants.

namespace std { enumfloat_denorm_style; enumfloat_round_style; template<class Ty> classnumeric_limits; } // namespace std

`float_denorm_style`

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

The enumeration describes the various methods that an implementation can choose for representing a denormalized floating-point value -- one too small to represent as a normalized value:

`denorm_indeterminate`

`denorm_absent`

`denorm_present`

`float_round_style`

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

The enumeration describes the various methods that an implementation can choose for rounding a floating-point value to an integer value:

`round_indeterminate`

`round_toward_zero`

`round_to_nearest`

`round_toward_infinity`

`round_toward_neg_infinity`

`numeric_limits`

template<class Ty> class numeric_limits { public: static constexpr float_denorm_stylehas_denorm= denorm_absent; static constexpr boolhas_denorm_loss= false; static constexpr boolhas_infinity= false; static constexpr boolhas_quiet_NaN= false; static constexpr boolhas_signaling_NaN= false; static constexpr boolis_bounded= false; static constexpr boolis_exact= false; static constexpr boolis_iec559= false; static constexpr boolis_integer= false; static constexpr boolis_modulo= false; static constexpr boolis_signed= false; static constexpr boolis_specialized= false; static constexpr booltinyness_before= false; static constexpr booltraps= false; static constexpr float_round_styleround_style= round_toward_zero; static constexpr intdigits= 0; static constexpr intdigits10= 0; static constexpr intmax_digits10= 0;[added with C++11]static constexpr intmax_exponent= 0; static constexpr intmax_exponent10= 0; static constexpr intmin_exponent= 0; static constexpr intmin_exponent10= 0; static constexpr intradix= 0; static constexpr Tydenorm_min() throw(); static constexpr Tyepsilon() throw(); static constexpr Tyinfinity() throw(); static constexpr Tylowest() throw();[added with C++11]static constexpr Tymax() throw(); static constexpr Tymin() throw(); static constexpr Tyquiet_NaN() throw(); static constexpr Tyround_error() throw(); static constexpr Tysignaling_NaN() throw(); };

The template class describes many arithmetic properties of its
parameter type `Ty`

. The header defines explicit specializations
for the types `wchar_t`

, *bool, char, signed char,
unsigned char, short, unsigned short, int, unsigned int, long,
unsigned long, float, double,* and *long double.*
Beginning with **C++11**,
it also defines explicit specializations for *long long,*
*unsigned long long,* `char16_t`

, and `char32_t`

.
In addition, the header defines the *const, volatile,* and *const volatile* variants of all these types. For all these
explicit specializations, the member `is_specialized`

is true,
and all relevant members have meaningful values.
The program can supply additional explicit specializations.

For an arbitrary specialization, *no* members have meaningful
values. A member object that does not have a meaningful value
stores zero (or false) and a member function that does not return
a meaningful value returns `Ty(0)`

.

`numeric_limits::denorm_min`

static constexpr Tydenorm_min() throw();

The function returns the minimum value for the type
(which is the same as
`min`

() if
`has_denorm`

is
not equal to
`denorm_present`

).

`numeric_limits::digits`

static constexpr intdigits= 0;

The member stores the number of
`radix`

digits
that the type can represent without change
(which is the number of bits other than any sign bit
for a predefined integer type, or the number of mantissa
digits for a predefined floating-point type).

`numeric_limits::digits10`

static constexpr intdigits10= 0;

The member stores the number of decimal digits that the type can represent without change.

`numeric_limits::epsilon`

static constexpr Tyepsilon() throw();

The function returns the difference between 1 and the smallest
value greater than 1 that is representable for the type
(which is the value
`FLT_EPSILON`

for type *float*).

`numeric_limits::has_denorm`

static constexpr float_denorm_stylehas_denorm= denorm_absent;

The member stores
`denorm_present`

for a floating-point type that has
denormalized values (effectively a variable number of exponent bits).

`numeric_limits::has_denorm_loss`

static constexpr boolhas_denorm_loss= false;

The member stores true for a type that determines whether a value has lost accuracy because it is delivered as a denormalized result (too small to represent as a normalized value) or because it is inexact (not the same as a result not subject to limitations of exponent range and precision), an option with IEC 559 floating-point representations that can affect some results.

`numeric_limits::has_infinity`

static constexpr boolhas_infinity= false;

The member stores true for a type that has
a representation for positive infinity.
True if `is_iec559`

is true.

`numeric_limits::has_quiet_NaN`

static constexpr boolhas_quiet_NaN= false;

The member stores true for a type that has
a representation for a **quiet NaN**,
an encoding that is ``Not a Number'' which does not
signal its presence in an expression.
True if `is_iec559`

is true.

`numeric_limits::has_signaling_NaN`

static constexpr boolhas_signaling_NaN= false;

The member stores true for a type that has
a representation for a **signaling NaN**,
an encoding that is ``Not a Number'' which
signals its presence in an expression
by reporting an exception.
True if `is_iec559`

is true.

`numeric_limits::infinity`

static constexpr Tyinfinity() throw();

The function returns the representation of positive infinity
for the type. The return value is meaningful only if
`has_infinity`

is true.

`numeric_limits::is_bounded`

static constexpr boolis_bounded= false;

The member stores true for a type that has a bounded set of representable values (which is the case for all predefined types).

`numeric_limits::is_exact`

static constexpr boolis_exact= false;

The member stores true for a type that has exact representations for all its values (which is the case for all predefined integer types). A fixed-point or rational representation is also considered exact, but not a floating-point representation.

`numeric_limits::is_iec559`

static constexpr boolis_iec559= false;

The member stores true for a type that has
a representation conforming to
**IEC 559**, an international
standard for representing floating-point values (also known as
**IEEE 754** in the USA).

`numeric_limits::is_integer`

static constexpr boolis_integer= false;

The member stores true for a type that has an integer representation (which is the case for all predefined integer types).

`numeric_limits::is_modulo`

static constexpr boolis_modulo= false;

The member stores true for a type that has a
**modulo representation**,
where all results are reduced modulo some value (which is the
case for all predefined unsigned integer types).

`numeric_limits::is_signed`

static constexpr boolis_signed= false;

The member stores true for a type that has a signed representation (which is the case for all predefined floating-point and signed integer types).

`numeric_limits::is_specialized`

static constexpr boolis_specialized= false;

The member stores true for a type that has
an explicit specialization defined for template class
`numeric_limits`

(which is the case for all scalar types other than pointers).

`numeric_limits::lowest`

static constexpr Tylowest() throw();[added with C++11]

The function returns the most negative finite value for the type
(which is typically
`min()`

for integer types and
`-max()`

for floating-point types).
The return value is meaningful if
`is_bounded`

is true.

`numeric_limits::max`

static constexpr Tymax() throw();

The function returns the maximum finite value for the type
(which is
`INT_MAX`

for type *int* and
`FLT_MAX`

for type *float*). The return value is meaningful if
`is_bounded`

is true.

`numeric_limits::max_digits10`

static constexpr intmax_digits10= 0;[added with C++11]

The member stores the number of decimal digits required to ensure that two distinct values of the type have distinct decimal representations. Meaningful only for floating-point types.

`numeric_limits::max_exponent`

static constexpr intmax_exponent= 0;

The member stores the maximum positive integer such that
the type can represent as a finite value
`radix`

raised to that power
minus one (which is the value
`FLT_MAX_EXP`

for type *float*).
Meaningful only for floating-point types.

`numeric_limits::max_exponent10`

static constexpr intmax_exponent10= 0;

The member stores the maximum positive integer such that
the type can represent as a finite value
10 raised to that power (which is the value
`FLT_MAX_10_EXP`

for type *float*).
Meaningful only for floating-point types.

`numeric_limits::min`

static constexpr Tymin() throw();

The function returns the minimum normalized value for the type
(which is
`INT_MIN`

for type *int* and
`FLT_MIN`

for type *float*). The return value is meaningful if
`is_bounded`

is true or
`is_bounded`

is false and
`is_signed`

is false.

`numeric_limits::min_exponent`

static constexpr intmin_exponent= 0;

The member stores the minimum negative integer such that
the type can represent as a normalized value
`radix`

raised to that power
minus one (which is the value
`FLT_MIN_EXP`

for type *float*).
Meaningful only for floating-point types.

`numeric_limits::min_exponent10`

static constexpr intmin_exponent10= 0;

The member stores the minimum negative integer such that
the type can represent as a normalized value
10 raised to that power
(which is the value
`FLT_MIN_10_EXP`

for type *float*).
Meaningful only for floating-point types.

`numeric_limits::quiet_NaN`

static constexpr Tyquiet_NaN() throw();

The function returns a representation of a
quiet NaN
for the type. The return value is meaningful only if
`has_quiet_NaN`

is true.

`numeric_limits::radix`

static constexpr intradix= 0;

The member stores the base of the representation
for the type (which is 2 for the predefined integer types,
and the base to which the exponent is raised, or
`FLT_RADIX`

,
for the predefined floating-point types).

`numeric_limits::round_error`

static constexpr Tyround_error() throw();

The function returns the maximum rounding error for the type.

`numeric_limits::round_style`

static constexpr float_round_styleround_style= round_toward_zero;

The member stores a value that describes the various methods that an implementation can choose for rounding a floating-point value to an integer value.

`numeric_limits::signaling_NaN`

static constexpr Tysignaling_NaN() throw();

The function returns a representation of a
signaling NaN
for the type. The return value is meaningful only if
`has_signaling_NaN`

is true.

`numeric_limits::tinyness_before`

static constexpr booltinyness_before= false;

The member stores true for a type that determines whether a value is ``tiny'' (too small to represent as a normalized value) before rounding, an option with IEC 559 floating-point representations that can affect some results.

`numeric_limits::traps`

static constexpr booltraps= false;

The member stores true for a type that generates some kind of signal to report certain arithmetic exceptions.

See also the
**Table of Contents** and the
**Index**.

*
Copyright © 1992-2013
by P.J. Plauger. All rights reserved.*