.\" ident @(#)numeric_limits.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH numeric_limits 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2numeric_limits\fP \ - A class for representing information about scalar types. .SH SPECIALIZATIONS .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .br numeric_limits .SH SYNOPSIS .br #include .br template .br class numeric_limits ; .SH DESCRIPTION numeric_limits is a class for representing information about scalar types. Specializations are included for each fundamental type, both floating point and integer, including \f2bool\fP. This class encapsulates information that is contained in the \f2\fP and \f2\fP headers, and includes additional information that is not contained in any existing C or C++ header. Not all of the information given by members is meaningful for all specializations of numeric_limits. Any value that is not meaningful for a particular type is set to \f20\fP or \f2false\fP. .SH INTERFACE .br template .br class numeric_limits { .br .br public: .br .RE .RS 1 // General -- meaningful for all specializations. .RE .RS 0 .RE .RS 3 static const bool is_specialized ; .br static T min () throw(); .br static T max () throw(); .br static const int radix ; .br static const int digits ; .br static const int digits10 ; .br static const bool is_signed ; .br static const bool is_integer ; .br static const bool is_exact ; .br static const bool traps ; .br static const bool is_modulo ; .br static const bool is_bounded ; .RE .RS 0 .RE .RS 1 // Floating point specific. .RE .RS 0 .RE .RS 3 static T epsilon () throw(); .br static T round_error () throw(); .br static const int min_exponent10 ; .br static const int max_exponent10 ; .br static const int min_exponent ; .br static const int max_exponent ; .br static const bool has_infinity ; .br static const bool has_quiet_NaN ; .br static const bool has_signaling_NaN ; .br static const bool is_iec559 ; .br static const float_denorm_style has_denorm ; .br static const bool has_denorm_loss; .br static const bool tinyness_before ; .br static const float_round_style round_style ; .br static T denorm_min () throw(); .br static T infinity () throw(); .br static T quiet_NaN () throw(); .br static T signaling_NaN () throw(); .RE .RS 1 }; .RE .RS 0 .br enum float_round_style { .RE .RS 2 round_indeterminate = -1, .br round_toward_zero = 0, .br round_to_nearest = 1, .br round_toward_infinity = 2, .br round_toward_neg_infinity = 3 .RE .RS 1 }; .RE .RS 0 enum float_denorm_style { .RE .RS 2 denorm_indeterminate = -1, .br denorm_absent = 0, .br denorm_present = 1 .RE .RS 1 }; .SH MEMBER FIELDS AND FUNCTIONS .RE .RS 0 static T .br denorm_min () throw(); .RE .RS 3 Returns the minimum denormalized value. Meaningful for all floating point types. For types that do not allow denormalized values, this method must return the minimum normalized value. .RE .br static const int .br digits ; .RE .RS 3 The number of radix digits that can be represented without change. For built-in integer types, \f2digits\fP is usually the number of non-sign bits in the representation. For floating point types, \f2digits\fP is the number of radix digits in the mantissa. This member is meaningful for all specializations that declare \f2is_bounded\fP to be \f2true\fP. .RE .br static const int .br digits10 ; .RE .RS 3 The number of base 10 digits that can be represented without change. This function is meaningful for all specializations that declare \f2is_bounded\fP to be \f2true\fP. .RE .br static T .br epsilon () throw(); .RE .RS 3 Returns the machine epsilon (the difference between \f21\fP and the least value greater than \f21\fP that is representable). This function is meaningful for floating point types only. .RE .br static const float_denorm_style .br has_denorm ; .RE .RS 3 Returns \f2denorm_present\fP if the type allows denormalized values. Returns \f2denorm_absent\fP if the type does not allow denormalized values. Returns \f2denorm_indeterminate\fP if it is indeterminate at compile time whether the type allows denormalized values. It is meaningful for floating point types only. .RE .br static const bool .br has_infinity ; .RE .RS 3 This field is \f2true\fP if the type has a representation for positive infinity. It is meaningful for floating point types only. This field must be \f2true\fP for any type claiming conformance to IEC 559. .RE .br static const bool .br has_quiet_NaN ; .RE .RS 3 This field is \f2true\fP if the type has a representation for a quiet (non-signaling) "Not a Number". It is meaningful for floating point types only and must be \f2true\fP for any type claiming conformance to IEC 559. .RE .br static const bool .br has_signaling_NaN ; .RE .RS 3 This field is \f2true\fP if the type has a representation for a signaling "Not a Number". It is meaningful for floating point types only, and must be \f2true\fP for any type claiming conformance to IEC 559. .RE .br static T .br infinity () throw(); .RE .RS 3 Returns the representation of positive infinity, if available. This member function is meaningful for only those specializations that declare \f2has_infinity\fP to be \f2true\fP. Required for any type claiming conformance to IEC 559. .RE .br static const bool .br is_bounded ; .RE .RS 3 This field is \f2true\fP if the set of values representable by the type is finite. All built-in C types are bounded; this member would be \f2false\fP for arbitrary precision types. .RE .br static const bool .br is_exact ; .RE .RS 3 This static member field is \f2true\fP if the type uses an exact representation. All integer types are exact, but not vice versa. For example, rational and fixed-exponent representations are exact but not integer. This member is meaningful for all specializations. .RE .br static const bool .br is_iec559 ; .RE .RS 3 This member is \f2true\fP if and only if the type adheres to the IEC 559 standard. It is meaningful for floating point types only. .RE .br static const bool .br is_integer ; .RE .RS 3 This member is \f2true\fP if the type is integer. This member is meaningful for all specializations. .RE .br static const bool .br is_modulo ; .RE .RS 3 This field is \f2true\fP if the type is modulo. Generally, this is \f2false\fP for floating types, \f2true\fP for unsigned integers, and \f2true\fP for signed integers on most machines. A type is modulo if it is possible to add two positive numbers and have a result that wraps around to a third number, which is less. .RE .br static const bool .br is_signed ; .RE .RS 3 This member is \f2true\fP if the type is signed. This member is meaningful for all specializations. .RE .br static const bool .br is_specialized ; .RE .RS 3 Indicates whether numeric_limits has been specialized for type \f2T\fP. This flag must be \f2true\fP for all specializations of \f2numeric_limits\fP. For the default numeric_limits template, this flag must be \f2false\fP. .RE .br static T .br max () throw(); .RE .RS 3 Returns the maximum finite value. This function is meaningful for all specializations that declare \f2is_bounded\fP to be \f2true\fP. .RE .br static const int .br max_exponent ; .RE .RS 3 The maximum positive integer such that the radix raised to the power one less than that integer is in range. This field is meaningful for floating point types only. .RE .br static const int .br max_exponent10 ; .RE .RS 3 The maximum positive integer such that 10 raised to that power is in range. This field is meaningful for floating point types only. .RE .br static T .br min () throw(); .RE .RS 3 Returns the minimum finite value. For floating point types with denormalization, \f2min()\fPmust return the minimum normalized value. The minimum denormalized value is given by \f2denorm_min()\fP. This function is meaningful for all specializations that declare \f2is_bounded\fP to be \f2true\fP, or \f2is_bounded == false && is_signed == false\fP. .RE .br static const int .br min_exponent ; .RE .RS 3 The minimum negative integer such that the radix raised to the power one less than that integer is in range. This field is meaningful for floating point types only. .RE .br static const int .br min_exponent10 ; .RE .RS 3 The minimum negative integer such that 10 raised to that power is in range. This field is meaningful for floating point types only. .RE .br static T .br quiet_NaN () throw(); .RE .RS 3 Returns the representation of a quiet "Not a Number", if available. This function is meaningful only for those specializations that declare \f2has_quiet_NaN\fP to be \f2true\fP. This field is required for any type claiming conformance to IEC 559. .RE .br static const int .br radix ; .RE .RS 3 For floating types, specifies the base or radix of the exponent representation (often 2). For integer types, this member must specify the base of the representation. This field is meaningful for all specializations. .RE .br static T .br round_error () throw(); .RE .RS 3 Returns the measure of the maximum rounding error. This function is meaningful for floating point types only. .RE .br static const float_round_style .br round_style ; .RE .RS 3 The rounding style for the type. Specializations for integer types must return \f2round_toward_zero\fP. This is meaningful for all floating point types. .RE .br static T .br signaling_NaN() throw(); .RE .RS 3 Returns the representation of a signaling "Not a Number", if available. This function is meaningful for only those specializations that declare \f2has_signaling_NaN\fP to be \f2true\fP. This function must be meaningful for any type claiming conformance to IEC 559. .RE .br static const bool .br tinyness_before ; .RE .RS 3 This member is \f2true\fP if \f2tinyness\fP is detected before rounding. It is meaningful for floating point types only. .RE .br static const bool .br traps ; .RE .RS 3 This field is \f2true\fP if trapping is implemented for this type. The \f2traps\fP field is meaningful for all specializations. .RE .SH EXAMPLE .br // .br // limits.cpp .br // .RE .RS 1 #include .br #include .RE .RS 0 using namespace std; .br .br .br int main() .RE .RS 1 { .RE .RS 4 numeric_limits float_info; .RE .RS 3 if (float_info.is_specialized && .RE .RS 7 float_info.has_infinity) .RE .RS 4 { .RE .RS 6 // get value of infinity .RE .RS 5 cout<< float_info.infinity() << endl; .RE .RS 4 } .RE .RS 3 return 0; .RE .RS 1 } .SH WARNINGS The specializations for \f2wide\fP \f2chars\fP and \f2bool\fP are only available if your compiler has implemented them as real types and not simulated them with typedefs. If your compiler does not support namespaces, then you do not need the using declaration for \f2std\fP. .SH SEE ALSO IEEE Standard for Binary Floating-Point Arithmetic, 345 East 47th Street, New York, NY 10017 Language Independent Arithmetic (LIA-1)