This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
<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).
namespace std { enum float_denorm_style; enum float_round_style; template<class Ty> class numeric_limits; };
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
-- presence or absence of denormalized forms cannot be determined
at translation time
denorm_absent
-- denormalized forms are absent
denorm_present
-- denormalized forms are 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
-- rounding method cannot be determined
round_toward_zero
-- round toward zero
round_to_nearest
-- round to nearest integer
round_toward_infinity
-- round away from zero
round_toward_neg_infinity
-- round to more negative integer
numeric_limits
template<class Ty> class numeric_limits { public: static const float_denorm_style has_denorm = denorm_absent; static const bool has_denorm_loss = false; static const bool has_infinity = false; static const bool has_quiet_NaN = false; static const bool has_signaling_NaN = false; static const bool is_bounded = false; static const bool is_exact = false; static const bool is_iec559 = false; static const bool is_integer = false; static const bool is_modulo = false; static const bool is_signed = false; static const bool is_specialized = false; static const bool tinyness_before = false; static const bool traps = false; static const float_round_style round_style = round_toward_zero; static const int digits = 0; static const int digits10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; static const int min_exponent = 0; static const int min_exponent10 = 0; static const int radix = 0; static Ty denorm_min() throw(); static Ty epsilon() throw(); static Ty infinity() throw(); static Ty max() throw(); static Ty min() throw(); static Ty quiet_NaN() throw(); static Ty round_error() throw(); static Ty signaling_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. 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 Ty denorm_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 const int digits = 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 const int digits10 = 0;
The member stores the number of decimal digits that the type can represent without change.
numeric_limits::epsilon
static Ty epsilon() 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 const float_denorm_style has_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 const bool has_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 const bool has_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 const bool has_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 const bool has_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 Ty infinity() 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 const bool is_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 const bool is_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 const bool is_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 const bool is_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 const bool is_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 const bool is_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 const bool is_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::max
static Ty max() 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_exponent
static const int max_exponent = 0;
The member stores the maximum positive integer such that
the type can represent as a finite value
radix
raised to that power
(which is the value
FLT_MAX_EXP
for type float).
Meaningful only for floating-point types.
numeric_limits::max_exponent10
static const int max_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 Ty min() 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 const int min_exponent = 0;
The member stores the minimum negative integer such that
the type can represent as a normalized value
radix
raised to that power
(which is the value
FLT_MIN_EXP
for type float).
Meaningful only for floating-point types.
numeric_limits::min_exponent10
static const int min_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 Ty quiet_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 const int radix = 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 Ty round_error() throw();
The function returns the maximum rounding error for the type.
numeric_limits::round_style
static const float_round_style round_style = round_toward_zero;
The member stores a value that describes the vaious methods that an implementation can choose for rounding a floating-point value to an integer value.
numeric_limits::signaling_NaN
static Ty signaling_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 const bool tinyness_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 const bool traps = 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-2002 by P.J. Plauger. All rights reserved.