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  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 "if the type is integral"?
00204     */
00205     static const bool is_integer = false;
00206     /** True if the type uses an exact representation.  "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."
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         "Not a Number."  */
00233     static const bool has_quiet_NaN = false;
00234     /** True if the type has a representation for a signaling
00235         "Not a Number."  */
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     /** "True if loss of accuracy is detected as a denormalization loss,
00240         rather than as an inexact result." [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     /** "True if the set of values representable by the type is finite.   All
00247         built-in types are bounded, this member would be false for arbitrary
00248     precision types." [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       /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */
00293       static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
00294       /** The representation of a signaling "Not a Number," if
00295           @c has_signaling_NaN. */
00296       static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
00297       /** The minimum positive denormalized value.  For types where
00298           @c has_denorm is false, this is the minimum positive normalized
00299       value.  */
00300       static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
00301     };
00302 
00303   // Now there follow 15 explicit specializations.  Yes, 15.  Make sure
00304   // you get the count right.
00305 
00306   /// numeric_limits<bool> specialization.
00307   template<>
00308     struct numeric_limits<bool>
00309     {
00310       static const bool is_specialized = true;
00311 
00312       static bool min() throw()
00313       { return false; }
00314       static bool max() throw()
00315       { return true; }
00316 
00317       static const int digits = 1;
00318       static const int digits10 = 0;
00319       static const bool is_signed = false;
00320       static const bool is_integer = true;
00321       static const bool is_exact = true;
00322       static const int radix = 2;
00323       static bool epsilon() throw()
00324       { return false; }
00325       static bool round_error() throw()
00326       { return false; }
00327 
00328       static const int min_exponent = 0;
00329       static const int min_exponent10 = 0;
00330       static const int max_exponent = 0;
00331       static const int max_exponent10 = 0;
00332 
00333       static const bool has_infinity = false;
00334       static const bool has_quiet_NaN = false;
00335       static const bool has_signaling_NaN = false;
00336       static const float_denorm_style has_denorm = denorm_absent;
00337       static const bool has_denorm_loss = false;
00338 
00339       static bool infinity() throw()
00340       { return false; }
00341       static bool quiet_NaN() throw()
00342       { return false; }
00343       static bool signaling_NaN() throw()
00344       { return false; }
00345       static bool denorm_min() throw()
00346       { return false; }
00347 
00348       static const bool is_iec559 = false;
00349       static const bool is_bounded = true;
00350       static const bool is_modulo = false;
00351 
00352       // It is not clear what it means for a boolean type to trap.
00353       // This is a DR on the LWG issue list.  Here, I use integer
00354       // promotion semantics.
00355       static const bool traps = __glibcxx_integral_traps;
00356       static const bool tinyness_before = false;
00357       static const float_round_style round_style = round_toward_zero;
00358     };
00359 
00360   /// numeric_limits<char> specialization.
00361   template<>
00362     struct numeric_limits<char>
00363     {
00364       static const bool is_specialized = true;
00365 
00366       static char min() throw()
00367       { return __glibcxx_min(char); }
00368       static char max() throw()
00369       { return __glibcxx_max(char); }
00370 
00371       static const int digits = __glibcxx_digits (char);
00372       static const int digits10 = __glibcxx_digits10 (char);
00373       static const bool is_signed = __glibcxx_signed (char);
00374       static const bool is_integer = true;
00375       static const bool is_exact = true;
00376       static const int radix = 2;
00377       static char epsilon() throw()
00378       { return 0; }
00379       static char round_error() throw()
00380       { return 0; }
00381 
00382       static const int min_exponent = 0;
00383       static const int min_exponent10 = 0;
00384       static const int max_exponent = 0;
00385       static const int max_exponent10 = 0;
00386 
00387       static const bool has_infinity = false;
00388       static const bool has_quiet_NaN = false;
00389       static const bool has_signaling_NaN = false;
00390       static const float_denorm_style has_denorm = denorm_absent;
00391       static const bool has_denorm_loss = false;
00392 
00393       static char infinity() throw()
00394       { return char(); }
00395       static char quiet_NaN() throw()
00396       { return char(); }
00397       static char signaling_NaN() throw()
00398       { return char(); }
00399       static char denorm_min() throw()
00400       { return static_cast<char>(0); }
00401 
00402       static const bool is_iec559 = false;
00403       static const bool is_bounded = true;
00404       static const bool is_modulo = true;
00405 
00406       static const bool traps = __glibcxx_integral_traps;
00407       static const bool tinyness_before = false;
00408       static const float_round_style round_style = round_toward_zero;
00409     };
00410 
00411   /// numeric_limits<signed char> specialization.
00412   template<>
00413     struct numeric_limits<signed char>
00414     {
00415       static const bool is_specialized = true;
00416 
00417       static signed char min() throw()
00418       { return -__SCHAR_MAX__ - 1; }
00419       static signed char max() throw()
00420       { return __SCHAR_MAX__; }
00421 
00422       static const int digits = __glibcxx_digits (signed char);
00423       static const int digits10 = __glibcxx_digits10 (signed char);
00424       static const bool is_signed = true;
00425       static const bool is_integer = true;
00426       static const bool is_exact = true;
00427       static const int radix = 2;
00428       static signed char epsilon() throw()
00429       { return 0; }
00430       static signed char round_error() throw()
00431       { return 0; }
00432 
00433       static const int min_exponent = 0;
00434       static const int min_exponent10 = 0;
00435       static const int max_exponent = 0;
00436       static const int max_exponent10 = 0;
00437 
00438       static const bool has_infinity = false;
00439       static const bool has_quiet_NaN = false;
00440       static const bool has_signaling_NaN = false;
00441       static const float_denorm_style has_denorm = denorm_absent;
00442       static const bool has_denorm_loss = false;
00443 
00444       static signed char infinity() throw()
00445       { return static_cast<signed char>(0); }
00446       static signed char quiet_NaN() throw()
00447       { return static_cast<signed char>(0); }
00448       static signed char signaling_NaN() throw()
00449       { return static_cast<signed char>(0); }
00450       static signed char denorm_min() throw()
00451       { return static_cast<signed char>(0); }
00452 
00453       static const bool is_iec559 = false;
00454       static const bool is_bounded = true;
00455       static const bool is_modulo = true;
00456 
00457       static const bool traps = __glibcxx_integral_traps;
00458       static const bool tinyness_before = false;
00459       static const float_round_style round_style = round_toward_zero;
00460     };
00461 
00462   /// numeric_limits<unsigned char> specialization.
00463   template<>
00464     struct numeric_limits<unsigned char>
00465     {
00466       static const bool is_specialized = true;
00467 
00468       static unsigned char min() throw()
00469       { return 0; }
00470       static unsigned char max() throw()
00471       { return __SCHAR_MAX__ * 2U + 1; }
00472 
00473       static const int digits = __glibcxx_digits (unsigned char);
00474       static const int digits10 = __glibcxx_digits10 (unsigned char);
00475       static const bool is_signed = false;
00476       static const bool is_integer = true;
00477       static const bool is_exact = true;
00478       static const int radix = 2;
00479       static unsigned char epsilon() throw()
00480       { return 0; }
00481       static unsigned char round_error() throw()
00482       { return 0; }
00483 
00484       static const int min_exponent = 0;
00485       static const int min_exponent10 = 0;
00486       static const int max_exponent = 0;
00487       static const int max_exponent10 = 0;
00488 
00489       static const bool has_infinity = false;
00490       static const bool has_quiet_NaN = false;
00491       static const bool has_signaling_NaN = false;
00492       static const float_denorm_style has_denorm = denorm_absent;
00493       static const bool has_denorm_loss = false;
00494 
00495       static unsigned char infinity() throw()
00496       { return static_cast<unsigned char>(0); }
00497       static unsigned char quiet_NaN() throw()
00498       { return static_cast<unsigned char>(0); }
00499       static unsigned char signaling_NaN() throw()
00500       { return static_cast<unsigned char>(0); }
00501       static unsigned char denorm_min() throw()
00502       { return static_cast<unsigned char>(0); }
00503 
00504       static const bool is_iec559 = false;
00505       static const bool is_bounded = true;
00506       static const bool is_modulo = true;
00507 
00508       static const bool traps = __glibcxx_integral_traps;
00509       static const bool tinyness_before = false;
00510       static const float_round_style round_style = round_toward_zero;
00511     };
00512 
00513   /// numeric_limits<wchar_t> specialization.
00514   template<>
00515     struct numeric_limits<wchar_t>
00516     {
00517       static const bool is_specialized = true;
00518 
00519       static wchar_t min() throw()
00520       { return __glibcxx_min (wchar_t); }
00521       static wchar_t max() throw()
00522       { return __glibcxx_max (wchar_t); }
00523 
00524       static const int digits = __glibcxx_digits (wchar_t);
00525       static const int digits10 = __glibcxx_digits10 (wchar_t);
00526       static const bool is_signed = __glibcxx_signed (wchar_t);
00527       static const bool is_integer = true;
00528       static const bool is_exact = true;
00529       static const int radix = 2;
00530       static wchar_t epsilon() throw()
00531       { return 0; }
00532       static wchar_t round_error() throw()
00533       { return 0; }
00534 
00535       static const int min_exponent = 0;
00536       static const int min_exponent10 = 0;
00537       static const int max_exponent = 0;
00538       static const int max_exponent10 = 0;
00539 
00540       static const bool has_infinity = false;
00541       static const bool has_quiet_NaN = false;
00542       static const bool has_signaling_NaN = false;
00543       static const float_denorm_style has_denorm = denorm_absent;
00544       static const bool has_denorm_loss = false;
00545 
00546       static wchar_t infinity() throw()
00547       { return wchar_t(); }
00548       static wchar_t quiet_NaN() throw()
00549       { return wchar_t(); }
00550       static wchar_t signaling_NaN() throw()
00551       { return wchar_t(); }
00552       static wchar_t denorm_min() throw()
00553       { return wchar_t(); }
00554 
00555       static const bool is_iec559 = false;
00556       static const bool is_bounded = true;
00557       static const bool is_modulo = true;
00558 
00559       static const bool traps = __glibcxx_integral_traps;
00560       static const bool tinyness_before = false;
00561       static const float_round_style round_style = round_toward_zero;
00562     };
00563 
00564 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00565   /// numeric_limits<char16_t> specialization.
00566   template<>
00567     struct numeric_limits<char16_t>
00568     {
00569       static const bool is_specialized = true;
00570 
00571       static char16_t min() throw()
00572       { return __glibcxx_min (char16_t); }
00573       static char16_t max() throw()
00574       { return __glibcxx_max (char16_t); }
00575 
00576       static const int digits = __glibcxx_digits (char16_t);
00577       static const int digits10 = __glibcxx_digits10 (char16_t);
00578       static const bool is_signed = __glibcxx_signed (char16_t);
00579       static const bool is_integer = true;
00580       static const bool is_exact = true;
00581       static const int radix = 2;
00582       static char16_t epsilon() throw()
00583       { return 0; }
00584       static char16_t round_error() throw()
00585       { return 0; }
00586 
00587       static const int min_exponent = 0;
00588       static const int min_exponent10 = 0;
00589       static const int max_exponent = 0;
00590       static const int max_exponent10 = 0;
00591 
00592       static const bool has_infinity = false;
00593       static const bool has_quiet_NaN = false;
00594       static const bool has_signaling_NaN = false;
00595       static const float_denorm_style has_denorm = denorm_absent;
00596       static const bool has_denorm_loss = false;
00597 
00598       static char16_t infinity() throw()
00599       { return char16_t(); }
00600       static char16_t quiet_NaN() throw()
00601       { return char16_t(); }
00602       static char16_t signaling_NaN() throw()
00603       { return char16_t(); }
00604       static char16_t denorm_min() throw()
00605       { return char16_t(); }
00606 
00607       static const bool is_iec559 = false;
00608       static const bool is_bounded = true;
00609       static const bool is_modulo = true;
00610 
00611       static const bool traps = __glibcxx_integral_traps;
00612       static const bool tinyness_before = false;
00613       static const float_round_style round_style = round_toward_zero;
00614     };
00615 
00616   /// numeric_limits<char32_t> specialization.
00617   template<>
00618     struct numeric_limits<char32_t>
00619     {
00620       static const bool is_specialized = true;
00621 
00622       static char32_t min() throw()
00623       { return __glibcxx_min (char32_t); }
00624       static char32_t max() throw()
00625       { return __glibcxx_max (char32_t); }
00626 
00627       static const int digits = __glibcxx_digits (char32_t);
00628       static const int digits10 = __glibcxx_digits10 (char32_t);
00629       static const bool is_signed = __glibcxx_signed (char32_t);
00630       static const bool is_integer = true;
00631       static const bool is_exact = true;
00632       static const int radix = 2;
00633       static char32_t epsilon() throw()
00634       { return 0; }
00635       static char32_t round_error() throw()
00636       { return 0; }
00637 
00638       static const int min_exponent = 0;
00639       static const int min_exponent10 = 0;
00640       static const int max_exponent = 0;
00641       static const int max_exponent10 = 0;
00642 
00643       static const bool has_infinity = false;
00644       static const bool has_quiet_NaN = false;
00645       static const bool has_signaling_NaN = false;
00646       static const float_denorm_style has_denorm = denorm_absent;
00647       static const bool has_denorm_loss = false;
00648 
00649       static char32_t infinity() throw()
00650       { return char32_t(); }
00651       static char32_t quiet_NaN() throw()
00652       { return char32_t(); }
00653       static char32_t signaling_NaN() throw()
00654       { return char32_t(); }
00655       static char32_t denorm_min() throw()
00656       { return char32_t(); }
00657 
00658       static const bool is_iec559 = false;
00659       static const bool is_bounded = true;
00660       static const bool is_modulo = true;
00661 
00662       static const bool traps = __glibcxx_integral_traps;
00663       static const bool tinyness_before = false;
00664       static const float_round_style round_style = round_toward_zero;
00665     };
00666 #endif
00667 
00668   /// numeric_limits<short> specialization.
00669   template<>
00670     struct numeric_limits<short>
00671     {
00672       static const bool is_specialized = true;
00673 
00674       static short min() throw()
00675       { return -__SHRT_MAX__ - 1; }
00676       static short max() throw()
00677       { return __SHRT_MAX__; }
00678 
00679       static const int digits = __glibcxx_digits (short);
00680       static const int digits10 = __glibcxx_digits10 (short);
00681       static const bool is_signed = true;
00682       static const bool is_integer = true;
00683       static const bool is_exact = true;
00684       static const int radix = 2;
00685       static short epsilon() throw()
00686       { return 0; }
00687       static short round_error() throw()
00688       { return 0; }
00689 
00690       static const int min_exponent = 0;
00691       static const int min_exponent10 = 0;
00692       static const int max_exponent = 0;
00693       static const int max_exponent10 = 0;
00694 
00695       static const bool has_infinity = false;
00696       static const bool has_quiet_NaN = false;
00697       static const bool has_signaling_NaN = false;
00698       static const float_denorm_style has_denorm = denorm_absent;
00699       static const bool has_denorm_loss = false;
00700 
00701       static short infinity() throw()
00702       { return short(); }
00703       static short quiet_NaN() throw()
00704       { return short(); }
00705       static short signaling_NaN() throw()
00706       { return short(); }
00707       static short denorm_min() throw()
00708       { return short(); }
00709 
00710       static const bool is_iec559 = false;
00711       static const bool is_bounded = true;
00712       static const bool is_modulo = true;
00713 
00714       static const bool traps = __glibcxx_integral_traps;
00715       static const bool tinyness_before = false;
00716       static const float_round_style round_style = round_toward_zero;
00717     };
00718 
00719   /// numeric_limits<unsigned short> specialization.
00720   template<>
00721     struct numeric_limits<unsigned short>
00722     {
00723       static const bool is_specialized = true;
00724 
00725       static unsigned short min() throw()
00726       { return 0; }
00727       static unsigned short max() throw()
00728       { return __SHRT_MAX__ * 2U + 1; }
00729 
00730       static const int digits = __glibcxx_digits (unsigned short);
00731       static const int digits10 = __glibcxx_digits10 (unsigned short);
00732       static const bool is_signed = false;
00733       static const bool is_integer = true;
00734       static const bool is_exact = true;
00735       static const int radix = 2;
00736       static unsigned short epsilon() throw()
00737       { return 0; }
00738       static unsigned short round_error() throw()
00739       { return 0; }
00740 
00741       static const int min_exponent = 0;
00742       static const int min_exponent10 = 0;
00743       static const int max_exponent = 0;
00744       static const int max_exponent10 = 0;
00745 
00746       static const bool has_infinity = false;
00747       static const bool has_quiet_NaN = false;
00748       static const bool has_signaling_NaN = false;
00749       static const float_denorm_style has_denorm = denorm_absent;
00750       static const bool has_denorm_loss = false;
00751 
00752       static unsigned short infinity() throw()
00753       { return static_cast<unsigned short>(0); }
00754       static unsigned short quiet_NaN() throw()
00755       { return static_cast<unsigned short>(0); }
00756       static unsigned short signaling_NaN() throw()
00757       { return static_cast<unsigned short>(0); }
00758       static unsigned short denorm_min() throw()
00759       { return static_cast<unsigned short>(0); }
00760 
00761       static const bool is_iec559 = false;
00762       static const bool is_bounded = true;
00763       static const bool is_modulo = true;
00764 
00765       static const bool traps = __glibcxx_integral_traps;
00766       static const bool tinyness_before = false;
00767       static const float_round_style round_style = round_toward_zero;
00768     };
00769 
00770   /// numeric_limits<int> specialization.
00771   template<>
00772     struct numeric_limits<int>
00773     {
00774       static const bool is_specialized = true;
00775 
00776       static int min() throw()
00777       { return -__INT_MAX__ - 1; }
00778       static int max() throw()
00779       { return __INT_MAX__; }
00780 
00781       static const int digits = __glibcxx_digits (int);
00782       static const int digits10 = __glibcxx_digits10 (int);
00783       static const bool is_signed = true;
00784       static const bool is_integer = true;
00785       static const bool is_exact = true;
00786       static const int radix = 2;
00787       static int epsilon() throw()
00788       { return 0; }
00789       static int round_error() throw()
00790       { return 0; }
00791 
00792       static const int min_exponent = 0;
00793       static const int min_exponent10 = 0;
00794       static const int max_exponent = 0;
00795       static const int max_exponent10 = 0;
00796 
00797       static const bool has_infinity = false;
00798       static const bool has_quiet_NaN = false;
00799       static const bool has_signaling_NaN = false;
00800       static const float_denorm_style has_denorm = denorm_absent;
00801       static const bool has_denorm_loss = false;
00802 
00803       static int infinity() throw()
00804       { return static_cast<int>(0); }
00805       static int quiet_NaN() throw()
00806       { return static_cast<int>(0); }
00807       static int signaling_NaN() throw()
00808       { return static_cast<int>(0); }
00809       static int denorm_min() throw()
00810       { return static_cast<int>(0); }
00811 
00812       static const bool is_iec559 = false;
00813       static const bool is_bounded = true;
00814       static const bool is_modulo = true;
00815 
00816       static const bool traps = __glibcxx_integral_traps;
00817       static const bool tinyness_before = false;
00818       static const float_round_style round_style = round_toward_zero;
00819     };
00820 
00821   /// numeric_limits<unsigned int> specialization.
00822   template<>
00823     struct numeric_limits<unsigned int>
00824     {
00825       static const bool is_specialized = true;
00826 
00827       static unsigned int min() throw()
00828       { return 0; }
00829       static unsigned int max() throw()
00830       { return __INT_MAX__ * 2U + 1; }
00831 
00832       static const int digits = __glibcxx_digits (unsigned int);
00833       static const int digits10 = __glibcxx_digits10 (unsigned int);
00834       static const bool is_signed = false;
00835       static const bool is_integer = true;
00836       static const bool is_exact = true;
00837       static const int radix = 2;
00838       static unsigned int epsilon() throw()
00839       { return 0; }
00840       static unsigned int round_error() throw()
00841       { return 0; }
00842 
00843       static const int min_exponent = 0;
00844       static const int min_exponent10 = 0;
00845       static const int max_exponent = 0;
00846       static const int max_exponent10 = 0;
00847 
00848       static const bool has_infinity = false;
00849       static const bool has_quiet_NaN = false;
00850       static const bool has_signaling_NaN = false;
00851       static const float_denorm_style has_denorm = denorm_absent;
00852       static const bool has_denorm_loss = false;
00853 
00854       static unsigned int infinity() throw()
00855       { return static_cast<unsigned int>(0); }
00856       static unsigned int quiet_NaN() throw()
00857       { return static_cast<unsigned int>(0); }
00858       static unsigned int signaling_NaN() throw()
00859       { return static_cast<unsigned int>(0); }
00860       static unsigned int denorm_min() throw()
00861       { return static_cast<unsigned int>(0); }
00862 
00863       static const bool is_iec559 = false;
00864       static const bool is_bounded = true;
00865       static const bool is_modulo = true;
00866 
00867       static const bool traps = __glibcxx_integral_traps;
00868       static const bool tinyness_before = false;
00869       static const float_round_style round_style = round_toward_zero;
00870     };
00871 
00872   /// numeric_limits<long> specialization.
00873   template<>
00874     struct numeric_limits<long>
00875     {
00876       static const bool is_specialized = true;
00877 
00878       static long min() throw()
00879       { return -__LONG_MAX__ - 1; }
00880       static long max() throw()
00881       { return __LONG_MAX__; }
00882 
00883       static const int digits = __glibcxx_digits (long);
00884       static const int digits10 = __glibcxx_digits10 (long);
00885       static const bool is_signed = true;
00886       static const bool is_integer = true;
00887       static const bool is_exact = true;
00888       static const int radix = 2;
00889       static long epsilon() throw()
00890       { return 0; }
00891       static long round_error() throw()
00892       { return 0; }
00893 
00894       static const int min_exponent = 0;
00895       static const int min_exponent10 = 0;
00896       static const int max_exponent = 0;
00897       static const int max_exponent10 = 0;
00898 
00899       static const bool has_infinity = false;
00900       static const bool has_quiet_NaN = false;
00901       static const bool has_signaling_NaN = false;
00902       static const float_denorm_style has_denorm = denorm_absent;
00903       static const bool has_denorm_loss = false;
00904 
00905       static long infinity() throw()
00906       { return static_cast<long>(0); }
00907       static long quiet_NaN() throw()
00908       { return static_cast<long>(0); }
00909       static long signaling_NaN() throw()
00910       { return static_cast<long>(0); }
00911       static long denorm_min() throw()
00912       { return static_cast<long>(0); }
00913 
00914       static const bool is_iec559 = false;
00915       static const bool is_bounded = true;
00916       static const bool is_modulo = true;
00917 
00918       static const bool traps = __glibcxx_integral_traps;
00919       static const bool tinyness_before = false;
00920       static const float_round_style round_style = round_toward_zero;
00921     };
00922 
00923   /// numeric_limits<unsigned long> specialization.
00924   template<>
00925     struct numeric_limits<unsigned long>
00926     {
00927       static const bool is_specialized = true;
00928 
00929       static unsigned long min() throw()
00930       { return 0; }
00931       static unsigned long max() throw()
00932       { return __LONG_MAX__ * 2UL + 1; }
00933 
00934       static const int digits = __glibcxx_digits (unsigned long);
00935       static const int digits10 = __glibcxx_digits10 (unsigned long);
00936       static const bool is_signed = false;
00937       static const bool is_integer = true;
00938       static const bool is_exact = true;
00939       static const int radix = 2;
00940       static unsigned long epsilon() throw()
00941       { return 0; }
00942       static unsigned long round_error() throw()
00943       { return 0; }
00944 
00945       static const int min_exponent = 0;
00946       static const int min_exponent10 = 0;
00947       static const int max_exponent = 0;
00948       static const int max_exponent10 = 0;
00949 
00950       static const bool has_infinity = false;
00951       static const bool has_quiet_NaN = false;
00952       static const bool has_signaling_NaN = false;
00953       static const float_denorm_style has_denorm = denorm_absent;
00954       static const bool has_denorm_loss = false;
00955 
00956       static unsigned long infinity() throw()
00957       { return static_cast<unsigned long>(0); }
00958       static unsigned long quiet_NaN() throw()
00959       { return static_cast<unsigned long>(0); }
00960       static unsigned long signaling_NaN() throw()
00961       { return static_cast<unsigned long>(0); }
00962       static unsigned long denorm_min() throw()
00963       { return static_cast<unsigned long>(0); }
00964 
00965       static const bool is_iec559 = false;
00966       static const bool is_bounded = true;
00967       static const bool is_modulo = true;
00968 
00969       static const bool traps = __glibcxx_integral_traps;
00970       static const bool tinyness_before = false;
00971       static const float_round_style round_style = round_toward_zero;
00972     };
00973 
00974   /// numeric_limits<long long> specialization.
00975   template<>
00976     struct numeric_limits<long long>
00977     {
00978       static const bool is_specialized = true;
00979 
00980       static long long min() throw()
00981       { return -__LONG_LONG_MAX__ - 1; }
00982       static long long max() throw()
00983       { return __LONG_LONG_MAX__; }
00984 
00985       static const int digits = __glibcxx_digits (long long);
00986       static const int digits10 = __glibcxx_digits10 (long long);
00987       static const bool is_signed = true;
00988       static const bool is_integer = true;
00989       static const bool is_exact = true;
00990       static const int radix = 2;
00991       static long long epsilon() throw()
00992       { return 0; }
00993       static long long round_error() throw()
00994       { return 0; }
00995 
00996       static const int min_exponent = 0;
00997       static const int min_exponent10 = 0;
00998       static const int max_exponent = 0;
00999       static const int max_exponent10 = 0;
01000 
01001       static const bool has_infinity = false;
01002       static const bool has_quiet_NaN = false;
01003       static const bool has_signaling_NaN = false;
01004       static const float_denorm_style has_denorm = denorm_absent;
01005       static const bool has_denorm_loss = false;
01006 
01007       static long long infinity() throw()
01008       { return static_cast<long long>(0); }
01009       static long long quiet_NaN() throw()
01010       { return static_cast<long long>(0); }
01011       static long long signaling_NaN() throw()
01012       { return static_cast<long long>(0); }
01013       static long long denorm_min() throw()
01014       { return static_cast<long long>(0); }
01015 
01016       static const bool is_iec559 = false;
01017       static const bool is_bounded = true;
01018       static const bool is_modulo = true;
01019 
01020       static const bool traps = __glibcxx_integral_traps;
01021       static const bool tinyness_before = false;
01022       static const float_round_style round_style = round_toward_zero;
01023     };
01024 
01025   /// numeric_limits<unsigned long long> specialization.
01026   template<>
01027     struct numeric_limits<unsigned long long>
01028     {
01029       static const bool is_specialized = true;
01030 
01031       static unsigned long long min() throw()
01032       { return 0; }
01033       static unsigned long long max() throw()
01034       { return __LONG_LONG_MAX__ * 2ULL + 1; }
01035 
01036       static const int digits = __glibcxx_digits (unsigned long long);
01037       static const int digits10 = __glibcxx_digits10 (unsigned long long);
01038       static const bool is_signed = false;
01039       static const bool is_integer = true;
01040       static const bool is_exact = true;
01041       static const int radix = 2;
01042       static unsigned long long epsilon() throw()
01043       { return 0; }
01044       static unsigned long long round_error() throw()
01045       { return 0; }
01046 
01047       static const int min_exponent = 0;
01048       static const int min_exponent10 = 0;
01049       static const int max_exponent = 0;
01050       static const int max_exponent10 = 0;
01051 
01052       static const bool has_infinity = false;
01053       static const bool has_quiet_NaN = false;
01054       static const bool has_signaling_NaN = false;
01055       static const float_denorm_style has_denorm = denorm_absent;
01056       static const bool has_denorm_loss = false;
01057 
01058       static unsigned long long infinity() throw()
01059       { return static_cast<unsigned long long>(0); }
01060       static unsigned long long quiet_NaN() throw()
01061       { return static_cast<unsigned long long>(0); }
01062       static unsigned long long signaling_NaN() throw()
01063       { return static_cast<unsigned long long>(0); }
01064       static unsigned long long denorm_min() throw()
01065       { return static_cast<unsigned long long>(0); }
01066 
01067       static const bool is_iec559 = false;
01068       static const bool is_bounded = true;
01069       static const bool is_modulo = true;
01070 
01071       static const bool traps = __glibcxx_integral_traps;
01072       static const bool tinyness_before = false;
01073       static const float_round_style round_style = round_toward_zero;
01074     };
01075 
01076   /// numeric_limits<float> specialization.
01077   template<>
01078     struct numeric_limits<float>
01079     {
01080       static const bool is_specialized = true;
01081 
01082       static float min() throw()
01083       { return __FLT_MIN__; }
01084       static float max() throw()
01085       { return __FLT_MAX__; }
01086 
01087       static const int digits = __FLT_MANT_DIG__;
01088       static const int digits10 = __FLT_DIG__;
01089       static const bool is_signed = true;
01090       static const bool is_integer = false;
01091       static const bool is_exact = false;
01092       static const int radix = __FLT_RADIX__;
01093       static float epsilon() throw()
01094       { return __FLT_EPSILON__; }
01095       static float round_error() throw()
01096       { return 0.5F; }
01097 
01098       static const int min_exponent = __FLT_MIN_EXP__;
01099       static const int min_exponent10 = __FLT_MIN_10_EXP__;
01100       static const int max_exponent = __FLT_MAX_EXP__;
01101       static const int max_exponent10 = __FLT_MAX_10_EXP__;
01102 
01103       static const bool has_infinity = __FLT_HAS_INFINITY__;
01104       static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
01105       static const bool has_signaling_NaN = has_quiet_NaN;
01106       static const float_denorm_style has_denorm
01107     = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
01108       static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
01109 
01110       static float infinity() throw()
01111       { return __builtin_huge_valf (); }
01112       static float quiet_NaN() throw()
01113       { return __builtin_nanf (""); }
01114       static float signaling_NaN() throw()
01115       { return __builtin_nansf (""); }
01116       static float denorm_min() throw()
01117       { return __FLT_DENORM_MIN__; }
01118 
01119       static const bool is_iec559
01120     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
01121       static const bool is_bounded = true;
01122       static const bool is_modulo = false;
01123 
01124       static const bool traps = __glibcxx_float_traps;
01125       static const bool tinyness_before = __glibcxx_float_tinyness_before;
01126       static const float_round_style round_style = round_to_nearest;
01127     };
01128 
01129 #undef __glibcxx_float_has_denorm_loss
01130 #undef __glibcxx_float_traps
01131 #undef __glibcxx_float_tinyness_before
01132 
01133   /// numeric_limits<double> specialization.
01134   template<>
01135     struct numeric_limits<double>
01136     {
01137       static const bool is_specialized = true;
01138 
01139       static double min() throw()
01140       { return __DBL_MIN__; }
01141       static double max() throw()
01142       { return __DBL_MAX__; }
01143 
01144       static const int digits = __DBL_MANT_DIG__;
01145       static const int digits10 = __DBL_DIG__;
01146       static const bool is_signed = true;
01147       static const bool is_integer = false;
01148       static const bool is_exact = false;
01149       static const int radix = __FLT_RADIX__;
01150       static double epsilon() throw()
01151       { return __DBL_EPSILON__; }
01152       static double round_error() throw()
01153       { return 0.5; }
01154 
01155       static const int min_exponent = __DBL_MIN_EXP__;
01156       static const int min_exponent10 = __DBL_MIN_10_EXP__;
01157       static const int max_exponent = __DBL_MAX_EXP__;
01158       static const int max_exponent10 = __DBL_MAX_10_EXP__;
01159 
01160       static const bool has_infinity = __DBL_HAS_INFINITY__;
01161       static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
01162       static const bool has_signaling_NaN = has_quiet_NaN;
01163       static const float_denorm_style has_denorm
01164     = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
01165       static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
01166 
01167       static double infinity() throw()
01168       { return __builtin_huge_val(); }
01169       static double quiet_NaN() throw()
01170       { return __builtin_nan (""); }
01171       static double signaling_NaN() throw()
01172       { return __builtin_nans (""); }
01173       static double denorm_min() throw()
01174       { return __DBL_DENORM_MIN__; }
01175 
01176       static const bool is_iec559
01177     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
01178       static const bool is_bounded = true;
01179       static const bool is_modulo = false;
01180 
01181       static const bool traps = __glibcxx_double_traps;
01182       static const bool tinyness_before = __glibcxx_double_tinyness_before;
01183       static const float_round_style round_style = round_to_nearest;
01184     };
01185 
01186 #undef __glibcxx_double_has_denorm_loss
01187 #undef __glibcxx_double_traps
01188 #undef __glibcxx_double_tinyness_before
01189 
01190   /// numeric_limits<long double> specialization.
01191   template<>
01192     struct numeric_limits<long double>
01193     {
01194       static const bool is_specialized = true;
01195 
01196       static long double min() throw()
01197       { return __LDBL_MIN__; }
01198       static long double max() throw()
01199       { return __LDBL_MAX__; }
01200 
01201       static const int digits = __LDBL_MANT_DIG__;
01202       static const int digits10 = __LDBL_DIG__;
01203       static const bool is_signed = true;
01204       static const bool is_integer = false;
01205       static const bool is_exact = false;
01206       static const int radix = __FLT_RADIX__;
01207       static long double epsilon() throw()
01208       { return __LDBL_EPSILON__; }
01209       static long double round_error() throw()
01210       { return 0.5L; }
01211 
01212       static const int min_exponent = __LDBL_MIN_EXP__;
01213       static const int min_exponent10 = __LDBL_MIN_10_EXP__;
01214       static const int max_exponent = __LDBL_MAX_EXP__;
01215       static const int max_exponent10 = __LDBL_MAX_10_EXP__;
01216 
01217       static const bool has_infinity = __LDBL_HAS_INFINITY__;
01218       static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
01219       static const bool has_signaling_NaN = has_quiet_NaN;
01220       static const float_denorm_style has_denorm
01221     = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
01222       static const bool has_denorm_loss
01223     = __glibcxx_long_double_has_denorm_loss;
01224 
01225       static long double infinity() throw()
01226       { return __builtin_huge_vall (); }
01227       static long double quiet_NaN() throw()
01228       { return __builtin_nanl (""); }
01229       static long double signaling_NaN() throw()
01230       { return __builtin_nansl (""); }
01231       static long double denorm_min() throw()
01232       { return __LDBL_DENORM_MIN__; }
01233 
01234       static const bool is_iec559
01235     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
01236       static const bool is_bounded = true;
01237       static const bool is_modulo = false;
01238 
01239       static const bool traps = __glibcxx_long_double_traps;
01240       static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
01241       static const float_round_style round_style = round_to_nearest;
01242     };
01243 
01244 #undef __glibcxx_long_double_has_denorm_loss
01245 #undef __glibcxx_long_double_traps
01246 #undef __glibcxx_long_double_tinyness_before
01247 
01248 _GLIBCXX_END_NAMESPACE
01249 
01250 #undef __glibcxx_signed
01251 #undef __glibcxx_min
01252 #undef __glibcxx_max
01253 #undef __glibcxx_digits
01254 #undef __glibcxx_digits10
01255 
01256 #endif // _GLIBCXX_NUMERIC_LIMITS

Generated on Tue Apr 21 13:13:28 2009 for libstdc++ by  doxygen 1.5.8