limits

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

Generated on 9 Feb 2010 for libstdc++ by  doxygen 1.6.1