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