Since a number of the members in the numeric_limits template specializations are meaningful only for floating point specializations, it is useful to separate the description of the members into common fields and floating-point specific fields.
Table 22 summarizes the information available through the numeric_limits static data members and functions.
bool
is_specialized
true if a specialization exists, false otherwise
T
min()
Smallest finite value
Corresponding constant: XXX_MIN
T
max()
Largest finite value
Corresponding constant: XXX_MAX
int
radix
The base of the representation
int
digits
Number of radix digits that can be represented without change
int
digits10
Number of base-10 digits that can be represented without change
bool
is_signed
true if the type is signed
bool
is_integer
true if the type is integer
bool
is_exact
true if the representation is exact
bool
is_bounded
true if representation is finite
bool
is_modulo
true if adding two positive values of type T can yield a result less than either value
bool
traps
true if trapping is implemented for the type
In the table above, the XXX prefix is replaced with CHAR, SCHAR, UCHAR, SHRT, USHRT, INT, UINT, LONG, and ULONG, respectively, for the corresponding values of types char, signed char, unsigned char, short, unsigned short, int, unsigned, long, and unsigned long, as appropriate. These manifest constants are defined in the header <climits>.
radix represents the internal base for the representation. For example, most machines use a base 2 radix for integer data values; however, some may also support a representation, such as BCD, that uses a different base. The digits member then represents the number of such radix values that can be held in a value. For an integer type, this would be the number of non-sign bits in the representation.
All fundamental types are bounded. However, an implementation might choose to include, for example, an infinite precision integer type that would not be bounded.
A type is modulo if the value resulting from the addition of two positive values can wrap around, that is, be smaller than either argument. The fundamental unsigned integer types are all modulo. Signed integer types are usually modulo. The fundamental floating point types typically are not modulo.
The members described in Table 23 are either specific to floating point values, or have a meaning slightly different for floating point values than the one described earlier for non-floating datatypes.
T
min()
Minimum positive normalized value
Corresponding constant: XXX_MIN
int
digits
Number of digits in the mantissa
Corresponding constant: XXX_MANT_DIG
int
radix
Base (or radix) of the exponent representation
Corresponding constant: FLT_RADIX
T
epsilon()
Difference between 1 and the least representable value greater than 1
Corresponding constant: XXX_EPSILON
T
round_error()
A measurement of the rounding error
int
min_exponent
Minimum negative exponent
Corresponding constant: XXX_MIN_EXP
int
min_exponent10
Minimum value such that 10 raised to that power is in range
Corresponding constant: XXX_MIN_10_EXP
int
max_exponent
Maximum positive exponent
Corresponding constant: XXX_MAX_EXP
int
max_exponent10
Maximum value such that 10 raised to that power is in range
Corresponding constant: XXX_MAX_10_EXP
bool
has_infinity
true if the type has a representation of positive infinity
T
infinity()
Representation of infinity, if available
Corresponding constant: INFINITY
bool
has_quiet_NaN
true if there is a representation of a Quiet \Q\QNot a Number"
T
quiet_NaN()
Representation of Quiet NaN, if available
Corresponding constant: NAN
bool
has_signaling_NaN
true if there is a representation for a Signaling NaN
T
signaling_NaN()
Representation of Signaling NaN, if available
bool
has_denorm
true if the representation allows denormalized values
T
denorm_min()
Minimum positive denormalized value
bool
is_iec559
true if representation adheres to IEC 559 standard.
bool
tinyness_before
true if tinyness is detected before rounding
float_round_style
round_style
Rounding style for type
Corresponding constant: FLT_ROUNDS
In the table above, the XXX prefix is replaced with FLT, DBL, and LDBL, respectively, for the corresponding values of types float, double, and long double. These manifest constants are defined in the header <cfloat>.
A NaN is a Not a Number. It is a set of representable values that nevertheless do not correspond to any numeric quantity. Many numeric algorithms manipulate such values. NANs are typically returned by numeric algorithms to indicate a result that is outside of the domain of the data type. For instance, the operations 0.0/0.0 or 0 * std::numeric_limits<double>::infinity() yield NAN or std::numeric_limits<double>::quiet_NaN(). NANs come in two flavors: quiet and signaling. A quiet NAN can be safely used in computations without the danger of triggering an exception. A signaling NAN can be copied, assigned, and compared without causing an exception; however, using it in an arithmetic expression triggers a hardware exception. A unique property of all NANs is that they do not compare equal to any number, including another NAN.
The IEC 559 standard is a standard approved by the International Electrotechnical Commission. It is the same as the IEEE standard 754. The standard precisely specifies the representation, many properties, and relationships of the fundamental floating point types.
The value returned by the member function round_style() is one of the following: round_indeterminate, round_toward_zero, round_to_nearest, round_toward_infinity, or round_toward_neg_infinity.