limits

Go to the documentation of this file.
00001 // The template and inlines for the -*- C++ -*- numeric_limits classes.
00002 
00003 // Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 /** @file limits
00031  *  This is a Standard C++ Library header.
00032  */
00033 
00034 // Note: this is not a conforming implementation.
00035 // Written by Gabriel Dos Reis <gdr@codesourcery.com>
00036 
00037 //
00038 // ISO 14882:1998
00039 // 18.2.1
00040 //
00041 
00042 #ifndef _GLIBCXX_NUMERIC_LIMITS
00043 #define _GLIBCXX_NUMERIC_LIMITS 1
00044 
00045 #pragma GCC system_header
00046 
00047 #include <bits/c++config.h>
00048 
00049 //
00050 // The numeric_limits<> traits document implementation-defined aspects
00051 // of fundamental arithmetic data types (integers and floating points).
00052 // From Standard C++ point of view, there are 13 such types:
00053 //   * integers
00054 //         bool                             (1)
00055 //         char, signed char, unsigned char         (3)
00056 //         short, unsigned short                (2)
00057 //         int, unsigned                    (2)
00058 //         long, unsigned long                  (2)
00059 //
00060 //   * floating points
00061 //         float                        (1)
00062 //         double                       (1)
00063 //         long double                      (1)
00064 //
00065 // GNU C++ undertstands (where supported by the host C-library)
00066 //   * integer
00067 //         long long, unsigned long long            (2)
00068 //
00069 // which brings us to 15 fundamental arithmetic data types in GNU C++.
00070 //
00071 //
00072 // Since a numeric_limits<> is a bit tricky to get right, we rely on
00073 // an interface composed of macros which should be defined in config/os
00074 // or config/cpu when they differ from the generic (read arbitrary)
00075 // definitions given here.
00076 //
00077 
00078 // These values can be overridden in the target configuration file.
00079 // The default values are appropriate for many 32-bit targets.
00080 
00081 // GCC only intrinsicly supports modulo integral types.  The only remaining
00082 // integral exceptional values is division by zero.  Only targets that do not
00083 // signal division by zero in some "hard to ignore" way should use false.
00084 #ifndef __glibcxx_integral_traps
00085 # define __glibcxx_integral_traps true
00086 #endif
00087 
00088 // float
00089 //
00090 
00091 // Default values.  Should be overriden in configuration files if necessary.
00092 
00093 #ifndef __glibcxx_float_has_denorm_loss
00094 #  define __glibcxx_float_has_denorm_loss false
00095 #endif
00096 #ifndef __glibcxx_float_traps
00097 #  define __glibcxx_float_traps false
00098 #endif
00099 #ifndef __glibcxx_float_tinyness_before
00100 #  define __glibcxx_float_tinyness_before false
00101 #endif
00102 
00103 // double
00104 
00105 // Default values.  Should be overriden in configuration files if necessary.
00106 
00107 #ifndef __glibcxx_double_has_denorm_loss
00108 #  define __glibcxx_double_has_denorm_loss false
00109 #endif
00110 #ifndef __glibcxx_double_traps
00111 #  define __glibcxx_double_traps false
00112 #endif
00113 #ifndef __glibcxx_double_tinyness_before
00114 #  define __glibcxx_double_tinyness_before false
00115 #endif
00116 
00117 // long double
00118 
00119 // Default values.  Should be overriden in configuration files if necessary.
00120 
00121 #ifndef __glibcxx_long_double_has_denorm_loss
00122 #  define __glibcxx_long_double_has_denorm_loss false
00123 #endif
00124 #ifndef __glibcxx_long_double_traps
00125 #  define __glibcxx_long_double_traps false
00126 #endif
00127 #ifndef __glibcxx_long_double_tinyness_before
00128 #  define __glibcxx_long_double_tinyness_before false
00129 #endif
00130 
00131 // You should not need to define any macros below this point.
00132 
00133 #define __glibcxx_signed(T) ((T)(-1) < 0)
00134 
00135 #define __glibcxx_min(T) \
00136   (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
00137 
00138 #define __glibcxx_max(T) \
00139   (__glibcxx_signed (T) ? ((T)1 << __glibcxx_digits (T)) - 1 : ~(T)0)
00140 
00141 #define __glibcxx_digits(T) \
00142   (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
00143 
00144 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
00145 #define __glibcxx_digits10(T) \
00146   (__glibcxx_digits (T) * 643 / 2136)
00147 
00148 
00149 namespace std
00150 {
00151   /**
00152    *  @brief Describes the rounding style for floating-point types.
00153    *
00154    *  This is used in the std::numeric_limits class.
00155   */
00156   enum float_round_style
00157   {
00158     round_indeterminate       = -1,    ///< Self-explanatory.
00159     round_toward_zero         = 0,     ///< Self-explanatory.
00160     round_to_nearest          = 1,     ///< To the nearest representable value.
00161     round_toward_infinity     = 2,     ///< Self-explanatory.
00162     round_toward_neg_infinity = 3      ///< Self-explanatory.
00163   };
00164 
00165   /**
00166    *  @brief Describes the denormalization for floating-point types.
00167    *
00168    *  These values represent the presence or absence of a variable number
00169    *  of exponent bits.  This type is used in the std::numeric_limits class.
00170   */
00171   enum float_denorm_style
00172   {
00173     /// Indeterminate at compile time whether denormalized values are allowed.
00174     denorm_indeterminate = -1,
00175     /// The type does not allow denormalized values.
00176     denorm_absent        = 0,
00177     /// The type allows denormalized values.
00178     denorm_present       = 1
00179   };
00180 
00181   /**
00182    *  @brief Part of std::numeric_limits.
00183    *
00184    *  The @c static @c const members are usable as integral constant
00185    *  expressions.
00186    *
00187    *  @note This is a seperate class for purposes of efficiency; you
00188    *        should only access these members as part of an instantiation
00189    *        of the std::numeric_limits class.
00190   */
00191   struct __numeric_limits_base
00192   {
00193     /** This will be true for all fundamental types (which have
00194         specializations), and false for everything else.  */
00195     static const bool is_specialized = false;
00196 
00197     /** The number of @c radix digits that be represented without change:  for
00198         integer types, the number of non-sign bits in the mantissa; for
00199         floating types, the number of @c radix digits in the mantissa.  */
00200     static const int digits = 0;
00201     /** The number of base 10 digits that can be represented without change. */
00202     static const int digits10 = 0;
00203     /** True if the type is signed.  */
00204     static const bool is_signed = false;
00205     /** True if the type is integer.
00206      *  @if maint
00207      *  Is this supposed to be "if the type is integral"?
00208      *  @endif
00209     */
00210     static const bool is_integer = false;
00211     /** True if the type uses an exact representation.  "All integer types are
00212         exact, but not all exact types are integer.  For example, rational and
00213         fixed-exponent representations are exact but not integer."
00214         [18.2.1.2]/15  */
00215     static const bool is_exact = false;
00216     /** For integer types, specifies the base of the representation.  For
00217         floating types, specifies the base of the exponent representation.  */
00218     static const int radix = 0;
00219 
00220     /** The minimum negative integer such that @c radix raised to the power of
00221         (one less than that integer) is a normalized floating point number.  */
00222     static const int min_exponent = 0;
00223     /** The minimum negative integer such that 10 raised to that power is in
00224         the range of normalized floating point numbers.  */
00225     static const int min_exponent10 = 0;
00226     /** The maximum positive integer such that @c radix raised to the power of
00227         (one less than that integer) is a representable finite floating point
00228     number.  */
00229     static const int max_exponent = 0;
00230     /** The maximum positive integer such that 10 raised to that power is in
00231         the range of representable finite floating point numbers.  */
00232     static const int max_exponent10 = 0;
00233 
00234     /** True if the type has a representation for positive infinity.  */
00235     static const bool has_infinity = false;
00236     /** True if the type has a representation for a quiet (non-signaling)
00237         "Not a Number."  */
00238     static const bool has_quiet_NaN = false;
00239     /** True if the type has a representation for a signaling
00240         "Not a Number."  */
00241     static const bool has_signaling_NaN = false;
00242     /** See std::float_denorm_style for more information.  */
00243     static const float_denorm_style has_denorm = denorm_absent;
00244     /** "True if loss of accuracy is detected as a denormalization loss,
00245         rather than as an inexact result." [18.2.1.2]/42  */
00246     static const bool has_denorm_loss = false;
00247 
00248     /** True if-and-only-if the type adheres to the IEC 559 standard, also
00249         known as IEEE 754.  (Only makes sense for floating point types.)  */
00250     static const bool is_iec559 = false;
00251     /** "True if the set of values representable by the type is finite.   All
00252         built-in types are bounded, this member would be false for arbitrary
00253     precision types." [18.2.1.2]/54  */
00254     static const bool is_bounded = false;
00255     /** True if the type is @e modulo, that is, if it is possible to add two
00256         positive numbers and have a result that wraps around to a third number
00257         that is less.  Typically false for floating types, true for unsigned
00258         integers, and true for signed integers.  */
00259     static const bool is_modulo = false;
00260 
00261     /** True if trapping is implemented for this type.  */
00262     static const bool traps = false;
00263     /** True if tinyness is detected before rounding.  (see IEC 559)  */
00264     static const bool tinyness_before = false;
00265     /** See std::float_round_style for more information.  This is only
00266         meaningful for floating types; integer types will all be
00267     round_toward_zero.  */
00268     static const float_round_style round_style = round_toward_zero;
00269   };
00270 
00271   /**
00272    *  @brief Properties of fundamental types.
00273    *
00274    *  This class allows a program to obtain information about the
00275    *  representation of a fundamental type on a given platform.  For
00276    *  non-fundamental types, the functions will return 0 and the data
00277    *  members will all be @c false.
00278    *
00279    *  @if maint
00280    *  _GLIBCXX_RESOLVE_LIB_DEFECTS:  DRs 201 and 184 (hi Gaby!) are
00281    *  noted, but not incorporated in this documented (yet).
00282    *  @endif
00283   */
00284   template<typename _Tp>
00285     struct numeric_limits : public __numeric_limits_base
00286     {
00287       /** The minimum finite value, or for floating types with
00288           denormalization, the minimum positive normalized value.  */
00289       static _Tp min() throw() { return static_cast<_Tp>(0); }
00290       /** The maximum finite value.  */
00291       static _Tp max() throw() { return static_cast<_Tp>(0); }
00292       /** The @e machine @e epsilon:  the difference between 1 and the least
00293           value greater than 1 that is representable.  */
00294       static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
00295       /** The maximum rounding error measurement (see LIA-1).  */
00296       static _Tp round_error() throw() { return static_cast<_Tp>(0); }
00297       /** The representation of positive infinity, if @c has_infinity.  */
00298       static _Tp infinity() throw()  { return static_cast<_Tp>(0); }
00299       /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */
00300       static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
00301       /** The representation of a signaling "Not a Number," if
00302           @c has_signaling_NaN. */
00303       static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
00304       /** The minimum positive denormalized value.  For types where
00305           @c has_denorm is false, this is the minimum positive normalized
00306       value.  */
00307       static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
00308     };
00309 
00310   // Now there follow 15 explicit specializations.  Yes, 15.  Make sure
00311   // you get the count right.
00312 
00313   /// numeric_limits<bool> specialization.
00314   template<>
00315     struct numeric_limits<bool>
00316     {
00317       static const bool is_specialized = true;
00318 
00319       static bool min() throw()
00320       { return false; }
00321       static bool max() throw()
00322       { return true; }
00323 
00324       static const int digits = 1;
00325       static const int digits10 = 0;
00326       static const bool is_signed = false;
00327       static const bool is_integer = true;
00328       static const bool is_exact = true;
00329       static const int radix = 2;
00330       static bool epsilon() throw()
00331       { return false; }
00332       static bool round_error() throw()
00333       { return false; }
00334 
00335       static const int min_exponent = 0;
00336       static const int min_exponent10 = 0;
00337       static const int max_exponent = 0;
00338       static const int max_exponent10 = 0;
00339 
00340       static const bool has_infinity = false;
00341       static const bool has_quiet_NaN = false;
00342       static const bool has_signaling_NaN = false;
00343       static const float_denorm_style has_denorm = denorm_absent;
00344       static const bool has_denorm_loss = false;
00345 
00346       static bool infinity() throw()
00347       { return false; }
00348       static bool quiet_NaN() throw()
00349       { return false; }
00350       static bool signaling_NaN() throw()
00351       { return false; }
00352       static bool denorm_min() throw()
00353       { return false; }
00354 
00355       static const bool is_iec559 = false;
00356       static const bool is_bounded = true;
00357       static const bool is_modulo = false;
00358 
00359       // It is not clear what it means for a boolean type to trap.
00360       // This is a DR on the LWG issue list.  Here, I use integer
00361       // promotion semantics.
00362       static const bool traps = __glibcxx_integral_traps;
00363       static const bool tinyness_before = false;
00364       static const float_round_style round_style = round_toward_zero;
00365     };
00366 
00367   /// numeric_limits<char> specialization.
00368   template<>
00369     struct numeric_limits<char>
00370     {
00371       static const bool is_specialized = true;
00372 
00373       static char min() throw()
00374       { return __glibcxx_min(char); }
00375       static char max() throw()
00376       { return __glibcxx_max(char); }
00377 
00378       static const int digits = __glibcxx_digits (char);
00379       static const int digits10 = __glibcxx_digits10 (char);
00380       static const bool is_signed = __glibcxx_signed (char);
00381       static const bool is_integer = true;
00382       static const bool is_exact = true;
00383       static const int radix = 2;
00384       static char epsilon() throw()
00385       { return 0; }
00386       static char round_error() throw()
00387       { return 0; }
00388 
00389       static const int min_exponent = 0;
00390       static const int min_exponent10 = 0;
00391       static const int max_exponent = 0;
00392       static const int max_exponent10 = 0;
00393 
00394       static const bool has_infinity = false;
00395       static const bool has_quiet_NaN = false;
00396       static const bool has_signaling_NaN = false;
00397       static const float_denorm_style has_denorm = denorm_absent;
00398       static const bool has_denorm_loss = false;
00399 
00400       static char infinity() throw()
00401       { return char(); }
00402       static char quiet_NaN() throw()
00403       { return char(); }
00404       static char signaling_NaN() throw()
00405       { return char(); }
00406       static char denorm_min() throw()
00407       { return static_cast<char>(0); }
00408 
00409       static const bool is_iec559 = false;
00410       static const bool is_bounded = true;
00411       static const bool is_modulo = true;
00412 
00413       static const bool traps = __glibcxx_integral_traps;
00414       static const bool tinyness_before = false;
00415       static const float_round_style round_style = round_toward_zero;
00416     };
00417 
00418   /// numeric_limits<signed char> specialization.
00419   template<>
00420     struct numeric_limits<signed char>
00421     {
00422       static const bool is_specialized = true;
00423 
00424       static signed char min() throw()
00425       { return -__SCHAR_MAX__ - 1; }
00426       static signed char max() throw()
00427       { return __SCHAR_MAX__; }
00428 
00429       static const int digits = __glibcxx_digits (signed char);
00430       static const int digits10 = __glibcxx_digits10 (signed char);
00431       static const bool is_signed = true;
00432       static const bool is_integer = true;
00433       static const bool is_exact = true;
00434       static const int radix = 2;
00435       static signed char epsilon() throw()
00436       { return 0; }
00437       static signed char round_error() throw()
00438       { return 0; }
00439 
00440       static const int min_exponent = 0;
00441       static const int min_exponent10 = 0;
00442       static const int max_exponent = 0;
00443       static const int max_exponent10 = 0;
00444 
00445       static const bool has_infinity = false;
00446       static const bool has_quiet_NaN = false;
00447       static const bool has_signaling_NaN = false;
00448       static const float_denorm_style has_denorm = denorm_absent;
00449       static const bool has_denorm_loss = false;
00450 
00451       static signed char infinity() throw()
00452       { return static_cast<signed char>(0); }
00453       static signed char quiet_NaN() throw()
00454       { return static_cast<signed char>(0); }
00455       static signed char signaling_NaN() throw()
00456       { return static_cast<signed char>(0); }
00457       static signed char denorm_min() throw()
00458       { return static_cast<signed char>(0); }
00459 
00460       static const bool is_iec559 = false;
00461       static const bool is_bounded = true;
00462       static const bool is_modulo = true;
00463 
00464       static const bool traps = __glibcxx_integral_traps;
00465       static const bool tinyness_before = false;
00466       static const float_round_style round_style = round_toward_zero;
00467     };
00468 
00469   /// numeric_limits<unsigned char> specialization.
00470   template<>
00471     struct numeric_limits<unsigned char>
00472     {
00473       static const bool is_specialized = true;
00474 
00475       static unsigned char min() throw()
00476       { return 0; }
00477       static unsigned char max() throw()
00478       { return __SCHAR_MAX__ * 2U + 1; }
00479 
00480       static const int digits = __glibcxx_digits (unsigned char);
00481       static const int digits10 = __glibcxx_digits10 (unsigned char);
00482       static const bool is_signed = false;
00483       static const bool is_integer = true;
00484       static const bool is_exact = true;
00485       static const int radix = 2;
00486       static unsigned char epsilon() throw()
00487       { return 0; }
00488       static unsigned char round_error() throw()
00489       { return 0; }
00490 
00491       static const int min_exponent = 0;
00492       static const int min_exponent10 = 0;
00493       static const int max_exponent = 0;
00494       static const int max_exponent10 = 0;
00495 
00496       static const bool has_infinity = false;
00497       static const bool has_quiet_NaN = false;
00498       static const bool has_signaling_NaN = false;
00499       static const float_denorm_style has_denorm = denorm_absent;
00500       static const bool has_denorm_loss = false;
00501 
00502       static unsigned char infinity() throw()
00503       { return static_cast<unsigned char>(0); }
00504       static unsigned char quiet_NaN() throw()
00505       { return static_cast<unsigned char>(0); }
00506       static unsigned char signaling_NaN() throw()
00507       { return static_cast<unsigned char>(0); }
00508       static unsigned char denorm_min() throw()
00509       { return static_cast<unsigned char>(0); }
00510 
00511       static const bool is_iec559 = false;
00512       static const bool is_bounded = true;
00513       static const bool is_modulo = true;
00514 
00515       static const bool traps = __glibcxx_integral_traps;
00516       static const bool tinyness_before = false;
00517       static const float_round_style round_style = round_toward_zero;
00518     };
00519 
00520   /// numeric_limits<wchar_t> specialization.
00521   template<>
00522     struct numeric_limits<wchar_t>
00523     {
00524       static const bool is_specialized = true;
00525 
00526       static wchar_t min() throw()
00527       { return __glibcxx_min (wchar_t); }
00528       static wchar_t max() throw()
00529       { return __glibcxx_max (wchar_t); }
00530 
00531       static const int digits = __glibcxx_digits (wchar_t);
00532       static const int digits10 = __glibcxx_digits10 (wchar_t);
00533       static const bool is_signed = __glibcxx_signed (wchar_t);
00534       static const bool is_integer = true;
00535       static const bool is_exact = true;
00536       static const int radix = 2;
00537       static wchar_t epsilon() throw()
00538       { return 0; }
00539       static wchar_t round_error() throw()
00540       { return 0; }
00541 
00542       static const int min_exponent = 0;
00543       static const int min_exponent10 = 0;
00544       static const int max_exponent = 0;
00545       static const int max_exponent10 = 0;
00546 
00547       static const bool has_infinity = false;
00548       static const bool has_quiet_NaN = false;
00549       static const bool has_signaling_NaN = false;
00550       static const float_denorm_style has_denorm = denorm_absent;
00551       static const bool has_denorm_loss = false;
00552 
00553       static wchar_t infinity() throw()
00554       { return wchar_t(); }
00555       static wchar_t quiet_NaN() throw()
00556       { return wchar_t(); }
00557       static wchar_t signaling_NaN() throw()
00558       { return wchar_t(); }
00559       static wchar_t denorm_min() throw()
00560       { return wchar_t(); }
00561 
00562       static const bool is_iec559 = false;
00563       static const bool is_bounded = true;
00564       static const bool is_modulo = true;
00565 
00566       static const bool traps = __glibcxx_integral_traps;
00567       static const bool tinyness_before = false;
00568       static const float_round_style round_style = round_toward_zero;
00569     };
00570 
00571   /// numeric_limits<short> specialization.
00572   template<>
00573     struct numeric_limits<short>
00574     {
00575       static const bool is_specialized = true;
00576 
00577       static short min() throw()
00578       { return -__SHRT_MAX__ - 1; }
00579       static short max() throw()
00580       { return __SHRT_MAX__; }
00581 
00582       static const int digits = __glibcxx_digits (short);
00583       static const int digits10 = __glibcxx_digits10 (short);
00584       static const bool is_signed = true;
00585       static const bool is_integer = true;
00586       static const bool is_exact = true;
00587       static const int radix = 2;
00588       static short epsilon() throw()
00589       { return 0; }
00590       static short round_error() throw()
00591       { return 0; }
00592 
00593       static const int min_exponent = 0;
00594       static const int min_exponent10 = 0;
00595       static const int max_exponent = 0;
00596       static const int max_exponent10 = 0;
00597 
00598       static const bool has_infinity = false;
00599       static const bool has_quiet_NaN = false;
00600       static const bool has_signaling_NaN = false;
00601       static const float_denorm_style has_denorm = denorm_absent;
00602       static const bool has_denorm_loss = false;
00603 
00604       static short infinity() throw()
00605       { return short(); }
00606       static short quiet_NaN() throw()
00607       { return short(); }
00608       static short signaling_NaN() throw()
00609       { return short(); }
00610       static short denorm_min() throw()
00611       { return short(); }
00612 
00613       static const bool is_iec559 = false;
00614       static const bool is_bounded = true;
00615       static const bool is_modulo = true;
00616 
00617       static const bool traps = __glibcxx_integral_traps;
00618       static const bool tinyness_before = false;
00619       static const float_round_style round_style = round_toward_zero;
00620     };
00621 
00622   /// numeric_limits<unsigned short> specialization.
00623   template<>
00624     struct numeric_limits<unsigned short>
00625     {
00626       static const bool is_specialized = true;
00627 
00628       static unsigned short min() throw()
00629       { return 0; }
00630       static unsigned short max() throw()
00631       { return __SHRT_MAX__ * 2U + 1; }
00632 
00633       static const int digits = __glibcxx_digits (unsigned short);
00634       static const int digits10 = __glibcxx_digits10 (unsigned short);
00635       static const bool is_signed = false;
00636       static const bool is_integer = true;
00637       static const bool is_exact = true;
00638       static const int radix = 2;
00639       static unsigned short epsilon() throw()
00640       { return 0; }
00641       static unsigned short round_error() throw()
00642       { return 0; }
00643 
00644       static const int min_exponent = 0;
00645       static const int min_exponent10 = 0;
00646       static const int max_exponent = 0;
00647       static const int max_exponent10 = 0;
00648 
00649       static const bool has_infinity = false;
00650       static const bool has_quiet_NaN = false;
00651       static const bool has_signaling_NaN = false;
00652       static const float_denorm_style has_denorm = denorm_absent;
00653       static const bool has_denorm_loss = false;
00654 
00655       static unsigned short infinity() throw()
00656       { return static_cast<unsigned short>(0); }
00657       static unsigned short quiet_NaN() throw()
00658       { return static_cast<unsigned short>(0); }
00659       static unsigned short signaling_NaN() throw()
00660       { return static_cast<unsigned short>(0); }
00661       static unsigned short denorm_min() throw()
00662       { return static_cast<unsigned short>(0); }
00663 
00664       static const bool is_iec559 = false;
00665       static const bool is_bounded = true;
00666       static const bool is_modulo = true;
00667 
00668       static const bool traps = __glibcxx_integral_traps;
00669       static const bool tinyness_before = false;
00670       static const float_round_style round_style = round_toward_zero;
00671     };
00672 
00673   /// numeric_limits<int> specialization.
00674   template<>
00675     struct numeric_limits<int>
00676     {
00677       static const bool is_specialized = true;
00678 
00679       static int min() throw()
00680       { return -__INT_MAX__ - 1; }
00681       static int max() throw()
00682       { return __INT_MAX__; }
00683 
00684       static const int digits = __glibcxx_digits (int);
00685       static const int digits10 = __glibcxx_digits10 (int);
00686       static const bool is_signed = true;
00687       static const bool is_integer = true;
00688       static const bool is_exact = true;
00689       static const int radix = 2;
00690       static int epsilon() throw()
00691       { return 0; }
00692       static int round_error() throw()
00693       { return 0; }
00694 
00695       static const int min_exponent = 0;
00696       static const int min_exponent10 = 0;
00697       static const int max_exponent = 0;
00698       static const int max_exponent10 = 0;
00699 
00700       static const bool has_infinity = false;
00701       static const bool has_quiet_NaN = false;
00702       static const bool has_signaling_NaN = false;
00703       static const float_denorm_style has_denorm = denorm_absent;
00704       static const bool has_denorm_loss = false;
00705 
00706       static int infinity() throw()
00707       { return static_cast<int>(0); }
00708       static int quiet_NaN() throw()
00709       { return static_cast<int>(0); }
00710       static int signaling_NaN() throw()
00711       { return static_cast<int>(0); }
00712       static int denorm_min() throw()
00713       { return static_cast<int>(0); }
00714 
00715       static const bool is_iec559 = false;
00716       static const bool is_bounded = true;
00717       static const bool is_modulo = true;
00718 
00719       static const bool traps = __glibcxx_integral_traps;
00720       static const bool tinyness_before = false;
00721       static const float_round_style round_style = round_toward_zero;
00722     };
00723 
00724   /// numeric_limits<unsigned int> specialization.
00725   template<>
00726     struct numeric_limits<unsigned int>
00727     {
00728       static const bool is_specialized = true;
00729 
00730       static unsigned int min() throw()
00731       { return 0; }
00732       static unsigned int max() throw()
00733       { return __INT_MAX__ * 2U + 1; }
00734 
00735       static const int digits = __glibcxx_digits (unsigned int);
00736       static const int digits10 = __glibcxx_digits10 (unsigned int);
00737       static const bool is_signed = false;
00738       static const bool is_integer = true;
00739       static const bool is_exact = true;
00740       static const int radix = 2;
00741       static unsigned int epsilon() throw()
00742       { return 0; }
00743       static unsigned int round_error() throw()
00744       { return 0; }
00745 
00746       static const int min_exponent = 0;
00747       static const int min_exponent10 = 0;
00748       static const int max_exponent = 0;
00749       static const int max_exponent10 = 0;
00750 
00751       static const bool has_infinity = false;
00752       static const bool has_quiet_NaN = false;
00753       static const bool has_signaling_NaN = false;
00754       static const float_denorm_style has_denorm = denorm_absent;
00755       static const bool has_denorm_loss = false;
00756 
00757       static unsigned int infinity() throw()
00758       { return static_cast<unsigned int>(0); }
00759       static unsigned int quiet_NaN() throw()
00760       { return static_cast<unsigned int>(0); }
00761       static unsigned int signaling_NaN() throw()
00762       { return static_cast<unsigned int>(0); }
00763       static unsigned int denorm_min() throw()
00764       { return static_cast<unsigned int>(0); }
00765 
00766       static const bool is_iec559 = false;
00767       static const bool is_bounded = true;
00768       static const bool is_modulo = true;
00769 
00770       static const bool traps = __glibcxx_integral_traps;
00771       static const bool tinyness_before = false;
00772       static const float_round_style round_style = round_toward_zero;
00773     };
00774 
00775   /// numeric_limits<long> specialization.
00776   template<>
00777     struct numeric_limits<long>
00778     {
00779       static const bool is_specialized = true;
00780 
00781       static long min() throw()
00782       { return -__LONG_MAX__ - 1; }
00783       static long max() throw()
00784       { return __LONG_MAX__; }
00785 
00786       static const int digits = __glibcxx_digits (long);
00787       static const int digits10 = __glibcxx_digits10 (long);
00788       static const bool is_signed = true;
00789       static const bool is_integer = true;
00790       static const bool is_exact = true;
00791       static const int radix = 2;
00792       static long epsilon() throw()
00793       { return 0; }
00794       static long round_error() throw()
00795       { return 0; }
00796 
00797       static const int min_exponent = 0;
00798       static const int min_exponent10 = 0;
00799       static const int max_exponent = 0;
00800       static const int max_exponent10 = 0;
00801 
00802       static const bool has_infinity = false;
00803       static const bool has_quiet_NaN = false;
00804       static const bool has_signaling_NaN = false;
00805       static const float_denorm_style has_denorm = denorm_absent;
00806       static const bool has_denorm_loss = false;
00807 
00808       static long infinity() throw()
00809       { return static_cast<long>(0); }
00810       static long quiet_NaN() throw()
00811       { return static_cast<long>(0); }
00812       static long signaling_NaN() throw()
00813       { return static_cast<long>(0); }
00814       static long denorm_min() throw()
00815       { return static_cast<long>(0); }
00816 
00817       static const bool is_iec559 = false;
00818       static const bool is_bounded = true;
00819       static const bool is_modulo = true;
00820 
00821       static const bool traps = __glibcxx_integral_traps;
00822       static const bool tinyness_before = false;
00823       static const float_round_style round_style = round_toward_zero;
00824     };
00825 
00826   /// numeric_limits<unsigned long> specialization.
00827   template<>
00828     struct numeric_limits<unsigned long>
00829     {
00830       static const bool is_specialized = true;
00831 
00832       static unsigned long min() throw()
00833       { return 0; }
00834       static unsigned long max() throw()
00835       { return __LONG_MAX__ * 2UL + 1; }
00836 
00837       static const int digits = __glibcxx_digits (unsigned long);
00838       static const int digits10 = __glibcxx_digits10 (unsigned long);
00839       static const bool is_signed = false;
00840       static const bool is_integer = true;
00841       static const bool is_exact = true;
00842       static const int radix = 2;
00843       static unsigned long epsilon() throw()
00844       { return 0; }
00845       static unsigned long round_error() throw()
00846       { return 0; }
00847 
00848       static const int min_exponent = 0;
00849       static const int min_exponent10 = 0;
00850       static const int max_exponent = 0;
00851       static const int max_exponent10 = 0;
00852 
00853       static const bool has_infinity = false;
00854       static const bool has_quiet_NaN = false;
00855       static const bool has_signaling_NaN = false;
00856       static const float_denorm_style has_denorm = denorm_absent;
00857       static const bool has_denorm_loss = false;
00858 
00859       static unsigned long infinity() throw()
00860       { return static_cast<unsigned long>(0); }
00861       static unsigned long quiet_NaN() throw()
00862       { return static_cast<unsigned long>(0); }
00863       static unsigned long signaling_NaN() throw()
00864       { return static_cast<unsigned long>(0); }
00865       static unsigned long denorm_min() throw()
00866       { return static_cast<unsigned long>(0); }
00867 
00868       static const bool is_iec559 = false;
00869       static const bool is_bounded = true;
00870       static const bool is_modulo = true;
00871 
00872       static const bool traps = __glibcxx_integral_traps;
00873       static const bool tinyness_before = false;
00874       static const float_round_style round_style = round_toward_zero;
00875     };
00876 
00877   /// numeric_limits<long long> specialization.
00878   template<>
00879     struct numeric_limits<long long>
00880     {
00881       static const bool is_specialized = true;
00882 
00883       static long long min() throw()
00884       { return -__LONG_LONG_MAX__ - 1; }
00885       static long long max() throw()
00886       { return __LONG_LONG_MAX__; }
00887 
00888       static const int digits = __glibcxx_digits (long long);
00889       static const int digits10 = __glibcxx_digits10 (long long);
00890       static const bool is_signed = true;
00891       static const bool is_integer = true;
00892       static const bool is_exact = true;
00893       static const int radix = 2;
00894       static long long epsilon() throw()
00895       { return 0; }
00896       static long long round_error() throw()
00897       { return 0; }
00898 
00899       static const int min_exponent = 0;
00900       static const int min_exponent10 = 0;
00901       static const int max_exponent = 0;
00902       static const int max_exponent10 = 0;
00903 
00904       static const bool has_infinity = false;
00905       static const bool has_quiet_NaN = false;
00906       static const bool has_signaling_NaN = false;
00907       static const float_denorm_style has_denorm = denorm_absent;
00908       static const bool has_denorm_loss = false;
00909 
00910       static long long infinity() throw()
00911       { return static_cast<long long>(0); }
00912       static long long quiet_NaN() throw()
00913       { return static_cast<long long>(0); }
00914       static long long signaling_NaN() throw()
00915       { return static_cast<long long>(0); }
00916       static long long denorm_min() throw()
00917       { return static_cast<long long>(0); }
00918 
00919       static const bool is_iec559 = false;
00920       static const bool is_bounded = true;
00921       static const bool is_modulo = true;
00922 
00923       static const bool traps = __glibcxx_integral_traps;
00924       static const bool tinyness_before = false;
00925       static const float_round_style round_style = round_toward_zero;
00926     };
00927 
00928   /// numeric_limits<unsigned long long> specialization.
00929   template<>
00930     struct numeric_limits<unsigned long long>
00931     {
00932       static const bool is_specialized = true;
00933 
00934       static unsigned long long min() throw()
00935       { return 0; }
00936       static unsigned long long max() throw()
00937       { return __LONG_LONG_MAX__ * 2ULL + 1; }
00938 
00939       static const int digits = __glibcxx_digits (unsigned long long);
00940       static const int digits10 = __glibcxx_digits10 (unsigned long long);
00941       static const bool is_signed = false;
00942       static const bool is_integer = true;
00943       static const bool is_exact = true;
00944       static const int radix = 2;
00945       static unsigned long long epsilon() throw()
00946       { return 0; }
00947       static unsigned long long round_error() throw()
00948       { return 0; }
00949 
00950       static const int min_exponent = 0;
00951       static const int min_exponent10 = 0;
00952       static const int max_exponent = 0;
00953       static const int max_exponent10 = 0;
00954 
00955       static const bool has_infinity = false;
00956       static const bool has_quiet_NaN = false;
00957       static const bool has_signaling_NaN = false;
00958       static const float_denorm_style has_denorm = denorm_absent;
00959       static const bool has_denorm_loss = false;
00960 
00961       static unsigned long long infinity() throw()
00962       { return static_cast<unsigned long long>(0); }
00963       static unsigned long long quiet_NaN() throw()
00964       { return static_cast<unsigned long long>(0); }
00965       static unsigned long long signaling_NaN() throw()
00966       { return static_cast<unsigned long long>(0); }
00967       static unsigned long long denorm_min() throw()
00968       { return static_cast<unsigned long long>(0); }
00969 
00970       static const bool is_iec559 = false;
00971       static const bool is_bounded = true;
00972       static const bool is_modulo = true;
00973 
00974       static const bool traps = __glibcxx_integral_traps;
00975       static const bool tinyness_before = false;
00976       static const float_round_style round_style = round_toward_zero;
00977     };
00978 
00979   /// numeric_limits<float> specialization.
00980   template<>
00981     struct numeric_limits<float>
00982     {
00983       static const bool is_specialized = true;
00984 
00985       static float min() throw()
00986       { return __FLT_MIN__; }
00987       static float max() throw()
00988       { return __FLT_MAX__; }
00989 
00990       static const int digits = __FLT_MANT_DIG__;
00991       static const int digits10 = __FLT_DIG__;
00992       static const bool is_signed = true;
00993       static const bool is_integer = false;
00994       static const bool is_exact = false;
00995       static const int radix = __FLT_RADIX__;
00996       static float epsilon() throw()
00997       { return __FLT_EPSILON__; }
00998       static float round_error() throw()
00999       { return 0.5F; }
01000 
01001       static const int min_exponent = __FLT_MIN_EXP__;
01002       static const int min_exponent10 = __FLT_MIN_10_EXP__;
01003       static const int max_exponent = __FLT_MAX_EXP__;
01004       static const int max_exponent10 = __FLT_MAX_10_EXP__;
01005 
01006       static const bool has_infinity = __FLT_HAS_INFINITY__;
01007       static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
01008       static const bool has_signaling_NaN = has_quiet_NaN;
01009       static const float_denorm_style has_denorm
01010     = bool(__FLT_DENORM_MIN__) ? denorm_present : denorm_absent;
01011       static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
01012 
01013       static float infinity() throw()
01014       { return __builtin_huge_valf (); }
01015       static float quiet_NaN() throw()
01016       { return __builtin_nanf (""); }
01017       static float signaling_NaN() throw()
01018       { return __builtin_nansf (""); }
01019       static float denorm_min() throw()
01020       { return __FLT_DENORM_MIN__; }
01021 
01022       static const bool is_iec559
01023     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
01024       static const bool is_bounded = true;
01025       static const bool is_modulo = false;
01026 
01027       static const bool traps = __glibcxx_float_traps;
01028       static const bool tinyness_before = __glibcxx_float_tinyness_before;
01029       static const float_round_style round_style = round_to_nearest;
01030     };
01031 
01032 #undef __glibcxx_float_has_denorm_loss
01033 #undef __glibcxx_float_traps
01034 #undef __glibcxx_float_tinyness_before
01035 
01036   /// numeric_limits<double> specialization.
01037   template<>
01038     struct numeric_limits<double>
01039     {
01040       static const bool is_specialized = true;
01041 
01042       static double min() throw()
01043       { return __DBL_MIN__; }
01044       static double max() throw()
01045       { return __DBL_MAX__; }
01046 
01047       static const int digits = __DBL_MANT_DIG__;
01048       static const int digits10 = __DBL_DIG__;
01049       static const bool is_signed = true;
01050       static const bool is_integer = false;
01051       static const bool is_exact = false;
01052       static const int radix = __FLT_RADIX__;
01053       static double epsilon() throw()
01054       { return __DBL_EPSILON__; }
01055       static double round_error() throw()
01056       { return 0.5; }
01057 
01058       static const int min_exponent = __DBL_MIN_EXP__;
01059       static const int min_exponent10 = __DBL_MIN_10_EXP__;
01060       static const int max_exponent = __DBL_MAX_EXP__;
01061       static const int max_exponent10 = __DBL_MAX_10_EXP__;
01062 
01063       static const bool has_infinity = __DBL_HAS_INFINITY__;
01064       static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
01065       static const bool has_signaling_NaN = has_quiet_NaN;
01066       static const float_denorm_style has_denorm
01067     = bool(__DBL_DENORM_MIN__) ? denorm_present : denorm_absent;
01068       static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
01069 
01070       static double infinity() throw()
01071       { return __builtin_huge_val(); }
01072       static double quiet_NaN() throw()
01073       { return __builtin_nan (""); }
01074       static double signaling_NaN() throw()
01075       { return __builtin_nans (""); }
01076       static double denorm_min() throw()
01077       { return __DBL_DENORM_MIN__; }
01078 
01079       static const bool is_iec559
01080     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
01081       static const bool is_bounded = true;
01082       static const bool is_modulo = false;
01083 
01084       static const bool traps = __glibcxx_double_traps;
01085       static const bool tinyness_before = __glibcxx_double_tinyness_before;
01086       static const float_round_style round_style = round_to_nearest;
01087     };
01088 
01089 #undef __glibcxx_double_has_denorm_loss
01090 #undef __glibcxx_double_traps
01091 #undef __glibcxx_double_tinyness_before
01092 
01093   /// numeric_limits<long double> specialization.
01094   template<>
01095     struct numeric_limits<long double>
01096     {
01097       static const bool is_specialized = true;
01098 
01099       static long double min() throw()
01100       { return __LDBL_MIN__; }
01101       static long double max() throw()
01102       { return __LDBL_MAX__; }
01103 
01104       static const int digits = __LDBL_MANT_DIG__;
01105       static const int digits10 = __LDBL_DIG__;
01106       static const bool is_signed = true;
01107       static const bool is_integer = false;
01108       static const bool is_exact = false;
01109       static const int radix = __FLT_RADIX__;
01110       static long double epsilon() throw()
01111       { return __LDBL_EPSILON__; }
01112       static long double round_error() throw()
01113       { return 0.5L; }
01114 
01115       static const int min_exponent = __LDBL_MIN_EXP__;
01116       static const int min_exponent10 = __LDBL_MIN_10_EXP__;
01117       static const int max_exponent = __LDBL_MAX_EXP__;
01118       static const int max_exponent10 = __LDBL_MAX_10_EXP__;
01119 
01120       static const bool has_infinity = __LDBL_HAS_INFINITY__;
01121       static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
01122       static const bool has_signaling_NaN = has_quiet_NaN;
01123       static const float_denorm_style has_denorm
01124     = bool(__LDBL_DENORM_MIN__) ? denorm_present : denorm_absent;
01125       static const bool has_denorm_loss
01126     = __glibcxx_long_double_has_denorm_loss;
01127 
01128       static long double infinity() throw()
01129       { return __builtin_huge_vall (); }
01130       static long double quiet_NaN() throw()
01131       { return __builtin_nanl (""); }
01132       static long double signaling_NaN() throw()
01133       { return __builtin_nansl (""); }
01134       static long double denorm_min() throw()
01135       { return __LDBL_DENORM_MIN__; }
01136 
01137       static const bool is_iec559
01138     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
01139       static const bool is_bounded = true;
01140       static const bool is_modulo = false;
01141 
01142       static const bool traps = __glibcxx_long_double_traps;
01143       static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
01144       static const float_round_style round_style = round_to_nearest;
01145     };
01146 
01147 #undef __glibcxx_long_double_has_denorm_loss
01148 #undef __glibcxx_long_double_traps
01149 #undef __glibcxx_long_double_tinyness_before
01150 
01151 } // namespace std
01152 
01153 #undef __glibcxx_signed
01154 #undef __glibcxx_min
01155 #undef __glibcxx_max
01156 #undef __glibcxx_digits
01157 #undef __glibcxx_digits10
01158 
01159 #endif // _GLIBCXX_NUMERIC_LIMITS

Generated on Thu Nov 1 17:35:59 2007 for libstdc++ by  doxygen 1.5.1