# limits

Go to the documentation of this file.

    00001 // The template and inlines for the -*- C++ -*- numeric_limits classes.
    00002
    00003 // Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    00004 //
    00005 // This file is part of the GNU ISO C++ Library.  This library is free
    00006 // software; you can redistribute it and/or modify it under the
    00007 // terms of the GNU General Public License as published by the
    00008 // Free Software Foundation; either version 2, or (at your option)
    00009 // any later version.
    00010
    00011 // This library is distributed in the hope that it will be useful,
    00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014 // GNU General Public License for more details.
    00015
    00016 // You should have received a copy of the GNU General Public License along
    00017 // with this library; see the file COPYING.  If not, write to the Free
    00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    00019 // USA.
    00020
    00021 // As a special exception, you may use this file as part of a free software
    00022 // library without restriction.  Specifically, if other files instantiate
    00023 // templates or use macros or inline functions from this file, or you compile
    00024 // this file and link it with other files to produce an executable, this
    00025 // file does not by itself cause the resulting executable to be covered by
    00026 // the GNU General Public License.  This exception does not however
    00027 // invalidate any other reasons why the executable file might be covered by
    00028 // the GNU General Public License.
    00029
    00030 // 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
    00043 #ifndef _CPP_NUMERIC_LIMITS
    00044 #define _CPP_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 __glibcpp_integral_traps
    00086 # define __glibcpp_integral_traps true
    00087 #endif
    00088
    00089 // float
    00090 //
    00091
    00092 // Default values.  Should be overriden in configuration files if necessary.
    00093
    00094 #ifndef __glibcpp_float_has_denorm_loss
    00095 #  define __glibcpp_float_has_denorm_loss false
    00096 #endif
    00097 #ifndef __glibcpp_float_traps
    00098 #  define __glibcpp_float_traps false
    00099 #endif
    00100 #ifndef __glibcpp_float_tinyness_before
    00101 #  define __glibcpp_float_tinyness_before false
    00102 #endif
    00103
    00104 // double
    00105
    00106 // Default values.  Should be overriden in configuration files if necessary.
    00107
    00108 #ifndef __glibcpp_double_has_denorm_loss
    00109 #  define __glibcpp_double_has_denorm_loss false
    00110 #endif
    00111 #ifndef __glibcpp_double_traps
    00112 #  define __glibcpp_double_traps false
    00113 #endif
    00114 #ifndef __glibcpp_double_tinyness_before
    00115 #  define __glibcpp_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 __glibcpp_long_double_has_denorm_loss
    00123 #  define __glibcpp_long_double_has_denorm_loss false
    00124 #endif
    00125 #ifndef __glibcpp_long_double_traps
    00126 #  define __glibcpp_long_double_traps false
    00127 #endif
    00128 #ifndef __glibcpp_long_double_tinyness_before
    00129 #  define __glibcpp_long_double_tinyness_before false
    00130 #endif
    00131
    00132 // You should not need to define any macros below this point.
    00133
    00134 #define __glibcpp_signed(T) ((T)(-1) < 0)
    00135
    00136 #define __glibcpp_min(T) \
    00137   (__glibcpp_signed (T) ? (T)1 << __glibcpp_digits (T) : (T)0)
    00138
    00139 #define __glibcpp_max(T) \
    00140   (__glibcpp_signed (T) ? ((T)1 << __glibcpp_digits (T)) - 1 : ~(T)0)
    00141
    00142 #define __glibcpp_digits(T) \
    00143   (sizeof(T) * __CHAR_BIT__ - __glibcpp_signed (T))
    00144
    00145 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
    00146 #define __glibcpp_digits10(T) \
    00147   (__glibcpp_digits (T) * 643 / 2136)
    00148
    00149
    00150 namespace std
    00151 {
    00152   enum float_round_style
    00153   {
    00154     round_indeterminate       = -1,
    00155     round_toward_zero         = 0,
    00156     round_to_nearest          = 1,
    00157     round_toward_infinity     = 2,
    00158     round_toward_neg_infinity = 3
    00159   };
    00160
    00161   enum float_denorm_style
    00162   {
    00163     denorm_indeterminate = -1,
    00164     denorm_absent        = 0,
    00165     denorm_present       = 1
    00166   };
    00167
    00168   //
    00169   // The primary class traits
    00170   //
    00171   struct __numeric_limits_base
    00172   {
    00173     static const bool is_specialized = false;
    00174
    00175     static const int digits = 0;
    00176     static const int digits10 = 0;
    00177     static const bool is_signed = false;
    00178     static const bool is_integer = false;
    00179     static const bool is_exact = false;
    00180     static const int radix = 0;
    00181
    00182     static const int min_exponent = 0;
    00183     static const int min_exponent10 = 0;
    00184     static const int max_exponent = 0;
    00185     static const int max_exponent10 = 0;
    00186
    00187     static const bool has_infinity = false;
    00188     static const bool has_quiet_NaN = false;
    00189     static const bool has_signaling_NaN = false;
    00190     static const float_denorm_style has_denorm = denorm_absent;
    00191     static const bool has_denorm_loss = false;
    00192
    00193     static const bool is_iec559 = false;
    00194     static const bool is_bounded = false;
    00195     static const bool is_modulo = false;
    00196
    00197     static const bool traps = false;
    00198     static const bool tinyness_before = false;
    00199     static const float_round_style round_style = round_toward_zero;
    00200   };
    00201
    00202   template<typename _Tp>
    00203     struct numeric_limits : public __numeric_limits_base
    00204     {
    00205       static _Tp min() throw() { return static_cast<_Tp>(0); }
    00206       static _Tp max() throw() { return static_cast<_Tp>(0); }
    00207       static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
    00208       static _Tp round_error() throw() { return static_cast<_Tp>(0); }
    00209       static _Tp infinity() throw()  { return static_cast<_Tp>(0); }
    00210       static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
    00211       static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
    00212       static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
    00213     };
    00214
    00215   // Now there follow 15 explicit specializations.  Yes, 15.  Make sure
    00216   // you get the count right.
    00217   template<>
    00218     struct numeric_limits<bool>
    00219     {
    00220       static const bool is_specialized = true;
    00221
    00222       static bool min() throw()
    00223       { return false; }
    00224       static bool max() throw()
    00225       { return true; }
    00226
    00227       static const int digits = 1;
    00228       static const int digits10 = 0;
    00229       static const bool is_signed = false;
    00230       static const bool is_integer = true;
    00231       static const bool is_exact = true;
    00232       static const int radix = 2;
    00233       static bool epsilon() throw()
    00234       { return false; }
    00235       static bool round_error() throw()
    00236       { return false; }
    00237
    00238       static const int min_exponent = 0;
    00239       static const int min_exponent10 = 0;
    00240       static const int max_exponent = 0;
    00241       static const int max_exponent10 = 0;
    00242
    00243       static const bool has_infinity = false;
    00244       static const bool has_quiet_NaN = false;
    00245       static const bool has_signaling_NaN = false;
    00246       static const float_denorm_style has_denorm = denorm_absent;
    00247       static const bool has_denorm_loss = false;
    00248
    00249       static bool infinity() throw()
    00250       { return false; }
    00251       static bool quiet_NaN() throw()
    00252       { return false; }
    00253       static bool signaling_NaN() throw()
    00254       { return false; }
    00255       static bool denorm_min() throw()
    00256       { return false; }
    00257
    00258       static const bool is_iec559 = false;
    00259       static const bool is_bounded = true;
    00260       static const bool is_modulo = false;
    00261
    00262       // It is not clear what it means for a boolean type to trap.
    00263       // This is a DR on the LWG issue list.  Here, I use integer
    00264       // promotion semantics.
    00265       static const bool traps = __glibcpp_integral_traps;
    00266       static const bool tinyness_before = false;
    00267       static const float_round_style round_style = round_toward_zero;
    00268     };
    00269
    00270   template<>
    00271     struct numeric_limits<char>
    00272     {
    00273       static const bool is_specialized = true;
    00274
    00275       static char min() throw()
    00276       { return __glibcpp_min(char); }
    00277       static char max() throw()
    00278       { return __glibcpp_max(char); }
    00279
    00280       static const int digits = __glibcpp_digits (char);
    00281       static const int digits10 = __glibcpp_digits10 (char);
    00282       static const bool is_signed = __glibcpp_signed (char);
    00283       static const bool is_integer = true;
    00284       static const bool is_exact = true;
    00285       static const int radix = 2;
    00286       static char epsilon() throw()
    00287       { return 0; }
    00288       static char round_error() throw()
    00289       { return 0; }
    00290
    00291       static const int min_exponent = 0;
    00292       static const int min_exponent10 = 0;
    00293       static const int max_exponent = 0;
    00294       static const int max_exponent10 = 0;
    00295
    00296       static const bool has_infinity = false;
    00297       static const bool has_quiet_NaN = false;
    00298       static const bool has_signaling_NaN = false;
    00299       static const float_denorm_style has_denorm = denorm_absent;
    00300       static const bool has_denorm_loss = false;
    00301
    00302       static char infinity() throw()
    00303       { return char(); }
    00304       static char quiet_NaN() throw()
    00305       { return char(); }
    00306       static char signaling_NaN() throw()
    00307       { return char(); }
    00308       static char denorm_min() throw()
    00309       { return static_cast<char>(0); }
    00310
    00311       static const bool is_iec559 = false;
    00312       static const bool is_bounded = true;
    00313       static const bool is_modulo = true;
    00314
    00315       static const bool traps = __glibcpp_integral_traps;
    00316       static const bool tinyness_before = false;
    00317       static const float_round_style round_style = round_toward_zero;
    00318     };
    00319
    00320   template<>
    00321     struct numeric_limits<signed char>
    00322     {
    00323       static const bool is_specialized = true;
    00324
    00325       static signed char min() throw()
    00326       { return -__SCHAR_MAX__ - 1; }
    00327       static signed char max() throw()
    00328       { return __SCHAR_MAX__; }
    00329
    00330       static const int digits = __glibcpp_digits (signed char);
    00331       static const int digits10 = __glibcpp_digits10 (signed char);
    00332       static const bool is_signed = true;
    00333       static const bool is_integer = true;
    00334       static const bool is_exact = true;
    00335       static const int radix = 2;
    00336       static signed char epsilon() throw()
    00337       { return 0; }
    00338       static signed char round_error() throw()
    00339       { return 0; }
    00340
    00341       static const int min_exponent = 0;
    00342       static const int min_exponent10 = 0;
    00343       static const int max_exponent = 0;
    00344       static const int max_exponent10 = 0;
    00345
    00346       static const bool has_infinity = false;
    00347       static const bool has_quiet_NaN = false;
    00348       static const bool has_signaling_NaN = false;
    00349       static const float_denorm_style has_denorm = denorm_absent;
    00350       static const bool has_denorm_loss = false;
    00351
    00352       static signed char infinity() throw()
    00353       { return static_cast<signed char>(0); }
    00354       static signed char quiet_NaN() throw()
    00355       { return static_cast<signed char>(0); }
    00356       static signed char signaling_NaN() throw()
    00357       { return static_cast<signed char>(0); }
    00358       static signed char denorm_min() throw()
    00359       { return static_cast<signed char>(0); }
    00360
    00361       static const bool is_iec559 = false;
    00362       static const bool is_bounded = true;
    00363       static const bool is_modulo = true;
    00364
    00365       static const bool traps = __glibcpp_integral_traps;
    00366       static const bool tinyness_before = false;
    00367       static const float_round_style round_style = round_toward_zero;
    00368     };
    00369
    00370   template<>
    00371     struct numeric_limits<unsigned char>
    00372     {
    00373       static const bool is_specialized = true;
    00374
    00375       static unsigned char min() throw()
    00376       { return 0; }
    00377       static unsigned char max() throw()
    00378       { return __SCHAR_MAX__ * 2U + 1; }
    00379
    00380       static const int digits = __glibcpp_digits (unsigned char);
    00381       static const int digits10 = __glibcpp_digits10 (unsigned char);
    00382       static const bool is_signed = false;
    00383       static const bool is_integer = true;
    00384       static const bool is_exact = true;
    00385       static const int radix = 2;
    00386       static unsigned char epsilon() throw()
    00387       { return 0; }
    00388       static unsigned char round_error() throw()
    00389       { return 0; }
    00390
    00391       static const int min_exponent = 0;
    00392       static const int min_exponent10 = 0;
    00393       static const int max_exponent = 0;
    00394       static const int max_exponent10 = 0;
    00395
    00396       static const bool has_infinity = false;
    00397       static const bool has_quiet_NaN = false;
    00398       static const bool has_signaling_NaN = false;
    00399       static const float_denorm_style has_denorm = denorm_absent;
    00400       static const bool has_denorm_loss = false;
    00401
    00402       static unsigned char infinity() throw()
    00403       { return static_cast<unsigned char>(0); }
    00404       static unsigned char quiet_NaN() throw()
    00405       { return static_cast<unsigned char>(0); }
    00406       static unsigned char signaling_NaN() throw()
    00407       { return static_cast<unsigned char>(0); }
    00408       static unsigned char denorm_min() throw()
    00409       { return static_cast<unsigned char>(0); }
    00410
    00411       static const bool is_iec559 = false;
    00412       static const bool is_bounded = true;
    00413       static const bool is_modulo = true;
    00414
    00415       static const bool traps = __glibcpp_integral_traps;
    00416       static const bool tinyness_before = false;
    00417       static const float_round_style round_style = round_toward_zero;
    00418     };
    00419
    00420   template<>
    00421     struct numeric_limits<wchar_t>
    00422     {
    00423       static const bool is_specialized = true;
    00424
    00425       static wchar_t min() throw()
    00426       { return __glibcpp_min (wchar_t); }
    00427       static wchar_t max() throw()
    00428       { return __glibcpp_max (wchar_t); }
    00429
    00430       static const int digits = __glibcpp_digits (wchar_t);
    00431       static const int digits10 = __glibcpp_digits10 (wchar_t);
    00432       static const bool is_signed = __glibcpp_signed (wchar_t);
    00433       static const bool is_integer = true;
    00434       static const bool is_exact = true;
    00435       static const int radix = 2;
    00436       static wchar_t epsilon() throw()
    00437       { return 0; }
    00438       static wchar_t 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 wchar_t infinity() throw()
    00453       { return wchar_t(); }
    00454       static wchar_t quiet_NaN() throw()
    00455       { return wchar_t(); }
    00456       static wchar_t signaling_NaN() throw()
    00457       { return wchar_t(); }
    00458       static wchar_t denorm_min() throw()
    00459       { return wchar_t(); }
    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 = __glibcpp_integral_traps;
    00466       static const bool tinyness_before = false;
    00467       static const float_round_style round_style = round_toward_zero;
    00468     };
    00469
    00470   template<>
    00471     struct numeric_limits<short>
    00472     {
    00473       static const bool is_specialized = true;
    00474
    00475       static short min() throw()
    00476       { return -__SHRT_MAX__ - 1; }
    00477       static short max() throw()
    00478       { return __SHRT_MAX__; }
    00479
    00480       static const int digits = __glibcpp_digits (short);
    00481       static const int digits10 = __glibcpp_digits10 (short);
    00482       static const bool is_signed = true;
    00483       static const bool is_integer = true;
    00484       static const bool is_exact = true;
    00485       static const int radix = 2;
    00486       static short epsilon() throw()
    00487       { return 0; }
    00488       static short round_error() throw()
    00489       { return 0; }
    00490
    00491       static const int min_exponent = 0;
    00492       static const int min_exponent10 = 0;
    00493       static const int max_exponent = 0;
    00494       static const int max_exponent10 = 0;
    00495
    00496       static const bool has_infinity = false;
    00497       static const bool has_quiet_NaN = false;
    00498       static const bool has_signaling_NaN = false;
    00499       static const float_denorm_style has_denorm = denorm_absent;
    00500       static const bool has_denorm_loss = false;
    00501
    00502       static short infinity() throw()
    00503       { return short(); }
    00504       static short quiet_NaN() throw()
    00505       { return short(); }
    00506       static short signaling_NaN() throw()
    00507       { return short(); }
    00508       static short denorm_min() throw()
    00509       { return short(); }
    00510
    00511       static const bool is_iec559 = true;
    00512       static const bool is_bounded = true;
    00513       static const bool is_modulo = true;
    00514
    00515       static const bool traps = __glibcpp_integral_traps;
    00516       static const bool tinyness_before = false;
    00517       static const float_round_style round_style = round_toward_zero;
    00518     };
    00519
    00520   template<>
    00521     struct numeric_limits<unsigned short>
    00522     {
    00523       static const bool is_specialized = true;
    00524
    00525       static unsigned short min() throw()
    00526       { return 0; }
    00527       static unsigned short max() throw()
    00528       { return __SHRT_MAX__ * 2U + 1; }
    00529
    00530       static const int digits = __glibcpp_digits (unsigned short);
    00531       static const int digits10 = __glibcpp_digits10 (unsigned short);
    00532       static const bool is_signed = false;
    00533       static const bool is_integer = true;
    00534       static const bool is_exact = true;
    00535       static const int radix = 2;
    00536       static unsigned short epsilon() throw()
    00537       { return 0; }
    00538       static unsigned short round_error() throw()
    00539       { return 0; }
    00540
    00541       static const int min_exponent = 0;
    00542       static const int min_exponent10 = 0;
    00543       static const int max_exponent = 0;
    00544       static const int max_exponent10 = 0;
    00545
    00546       static const bool has_infinity = false;
    00547       static const bool has_quiet_NaN = false;
    00548       static const bool has_signaling_NaN = false;
    00549       static const float_denorm_style has_denorm = denorm_absent;
    00550       static const bool has_denorm_loss = false;
    00551
    00552       static unsigned short infinity() throw()
    00553       { return static_cast<unsigned short>(0); }
    00554       static unsigned short quiet_NaN() throw()
    00555       { return static_cast<unsigned short>(0); }
    00556       static unsigned short signaling_NaN() throw()
    00557       { return static_cast<unsigned short>(0); }
    00558       static unsigned short denorm_min() throw()
    00559       { return static_cast<unsigned short>(0); }
    00560
    00561       static const bool is_iec559 = true;
    00562       static const bool is_bounded = true;
    00563       static const bool is_modulo = true;
    00564
    00565       static const bool traps = __glibcpp_integral_traps;
    00566       static const bool tinyness_before = false;
    00567       static const float_round_style round_style = round_toward_zero;
    00568     };
    00569
    00570   template<>
    00571     struct numeric_limits<int>
    00572     {
    00573       static const bool is_specialized = true;
    00574
    00575       static int min() throw()
    00576       { return -__INT_MAX__ - 1; }
    00577       static int max() throw()
    00578       { return __INT_MAX__; }
    00579
    00580       static const int digits = __glibcpp_digits (int);
    00581       static const int digits10 = __glibcpp_digits10 (int);
    00582       static const bool is_signed = true;
    00583       static const bool is_integer = true;
    00584       static const bool is_exact = true;
    00585       static const int radix = 2;
    00586       static int epsilon() throw()
    00587       { return 0; }
    00588       static int round_error() throw()
    00589       { return 0; }
    00590
    00591       static const int min_exponent = 0;
    00592       static const int min_exponent10 = 0;
    00593       static const int max_exponent = 0;
    00594       static const int max_exponent10 = 0;
    00595
    00596       static const bool has_infinity = false;
    00597       static const bool has_quiet_NaN = false;
    00598       static const bool has_signaling_NaN = false;
    00599       static const float_denorm_style has_denorm = denorm_absent;
    00600       static const bool has_denorm_loss = false;
    00601
    00602       static int infinity() throw()
    00603       { return static_cast<int>(0); }
    00604       static int quiet_NaN() throw()
    00605       { return static_cast<int>(0); }
    00606       static int signaling_NaN() throw()
    00607       { return static_cast<int>(0); }
    00608       static int denorm_min() throw()
    00609       { return static_cast<int>(0); }
    00610
    00611       static const bool is_iec559 = true;
    00612       static const bool is_bounded = true;
    00613       static const bool is_modulo = true;
    00614
    00615       static const bool traps = __glibcpp_integral_traps;
    00616       static const bool tinyness_before = false;
    00617       static const float_round_style round_style = round_toward_zero;
    00618     };
    00619
    00620   template<>
    00621     struct numeric_limits<unsigned int>
    00622     {
    00623       static const bool is_specialized = true;
    00624
    00625       static unsigned int min() throw()
    00626       { return 0; }
    00627       static unsigned int max() throw()
    00628       { return __INT_MAX__ * 2U + 1; }
    00629
    00630       static const int digits = __glibcpp_digits (unsigned int);
    00631       static const int digits10 = __glibcpp_digits10 (unsigned int);
    00632       static const bool is_signed = false;
    00633       static const bool is_integer = true;
    00634       static const bool is_exact = true;
    00635       static const int radix = 2;
    00636       static unsigned int epsilon() throw()
    00637       { return 0; }
    00638       static unsigned int round_error() throw()
    00639       { return 0; }
    00640
    00641       static const int min_exponent = 0;
    00642       static const int min_exponent10 = 0;
    00643       static const int max_exponent = 0;
    00644       static const int max_exponent10 = 0;
    00645
    00646       static const bool has_infinity = false;
    00647       static const bool has_quiet_NaN = false;
    00648       static const bool has_signaling_NaN = false;
    00649       static const float_denorm_style has_denorm = denorm_absent;
    00650       static const bool has_denorm_loss = false;
    00651
    00652       static unsigned int infinity() throw()
    00653       { return static_cast<unsigned int>(0); }
    00654       static unsigned int quiet_NaN() throw()
    00655       { return static_cast<unsigned int>(0); }
    00656       static unsigned int signaling_NaN() throw()
    00657       { return static_cast<unsigned int>(0); }
    00658       static unsigned int denorm_min() throw()
    00659       { return static_cast<unsigned int>(0); }
    00660
    00661       static const bool is_iec559 = true;
    00662       static const bool is_bounded = true;
    00663       static const bool is_modulo = true;
    00664
    00665       static const bool traps = __glibcpp_integral_traps;
    00666       static const bool tinyness_before = false;
    00667       static const float_round_style round_style = round_toward_zero;
    00668     };
    00669
    00670   template<>
    00671     struct numeric_limits<long>
    00672     {
    00673       static const bool is_specialized = true;
    00674
    00675       static long min() throw()
    00676       { return -__LONG_MAX__ - 1; }
    00677       static long max() throw()
    00678       { return __LONG_MAX__; }
    00679
    00680       static const int digits = __glibcpp_digits (long);
    00681       static const int digits10 = __glibcpp_digits10 (long);
    00682       static const bool is_signed = true;
    00683       static const bool is_integer = true;
    00684       static const bool is_exact = true;
    00685       static const int radix = 2;
    00686       static long epsilon() throw()
    00687       { return 0; }
    00688       static long round_error() throw()
    00689       { return 0; }
    00690
    00691       static const int min_exponent = 0;
    00692       static const int min_exponent10 = 0;
    00693       static const int max_exponent = 0;
    00694       static const int max_exponent10 = 0;
    00695
    00696       static const bool has_infinity = false;
    00697       static const bool has_quiet_NaN = false;
    00698       static const bool has_signaling_NaN = false;
    00699       static const float_denorm_style has_denorm = denorm_absent;
    00700       static const bool has_denorm_loss = false;
    00701
    00702       static long infinity() throw()
    00703       { return static_cast<long>(0); }
    00704       static long quiet_NaN() throw()
    00705       { return static_cast<long>(0); }
    00706       static long signaling_NaN() throw()
    00707       { return static_cast<long>(0); }
    00708       static long denorm_min() throw()
    00709       { return static_cast<long>(0); }
    00710
    00711       static const bool is_iec559 = true;
    00712       static const bool is_bounded = true;
    00713       static const bool is_modulo = true;
    00714
    00715       static const bool traps = __glibcpp_integral_traps;
    00716       static const bool tinyness_before = false;
    00717       static const float_round_style round_style = round_toward_zero;
    00718     };
    00719
    00720   template<>
    00721     struct numeric_limits<unsigned long>
    00722     {
    00723       static const bool is_specialized = true;
    00724
    00725       static unsigned long min() throw()
    00726       { return 0; }
    00727       static unsigned long max() throw()
    00728       { return __LONG_MAX__ * 2UL + 1; }
    00729
    00730       static const int digits = __glibcpp_digits (unsigned long);
    00731       static const int digits10 = __glibcpp_digits10 (unsigned long);
    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 long epsilon() throw()
    00737       { return 0; }
    00738       static unsigned long 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 long infinity() throw()
    00753       { return static_cast<unsigned long>(0); }
    00754       static unsigned long quiet_NaN() throw()
    00755       { return static_cast<unsigned long>(0); }
    00756       static unsigned long signaling_NaN() throw()
    00757       { return static_cast<unsigned long>(0); }
    00758       static unsigned long denorm_min() throw()
    00759       { return static_cast<unsigned long>(0); }
    00760
    00761       static const bool is_iec559 = true;
    00762       static const bool is_bounded = true;
    00763       static const bool is_modulo = true;
    00764
    00765       static const bool traps = __glibcpp_integral_traps;
    00766       static const bool tinyness_before = false;
    00767       static const float_round_style round_style = round_toward_zero;
    00768     };
    00769
    00770   template<>
    00771     struct numeric_limits<long long>
    00772     {
    00773       static const bool is_specialized = true;
    00774
    00775       static long long min() throw()
    00776       { return -__LONG_LONG_MAX__ - 1; }
    00777       static long long max() throw()
    00778       { return __LONG_LONG_MAX__; }
    00779
    00780       static const int digits = __glibcpp_digits (long long);
    00781       static const int digits10 = __glibcpp_digits10 (long long);
    00782       static const bool is_signed = true;
    00783       static const bool is_integer = true;
    00784       static const bool is_exact = true;
    00785       static const int radix = 2;
    00786       static long long epsilon() throw()
    00787       { return 0; }
    00788       static long long round_error() throw()
    00789       { return 0; }
    00790
    00791       static const int min_exponent = 0;
    00792       static const int min_exponent10 = 0;
    00793       static const int max_exponent = 0;
    00794       static const int max_exponent10 = 0;
    00795
    00796       static const bool has_infinity = false;
    00797       static const bool has_quiet_NaN = false;
    00798       static const bool has_signaling_NaN = false;
    00799       static const float_denorm_style has_denorm = denorm_absent;
    00800       static const bool has_denorm_loss = false;
    00801
    00802       static long long infinity() throw()
    00803       { return static_cast<long long>(0); }
    00804       static long long quiet_NaN() throw()
    00805       { return static_cast<long long>(0); }
    00806       static long long signaling_NaN() throw()
    00807       { return static_cast<long long>(0); }
    00808       static long long denorm_min() throw()
    00809       { return static_cast<long long>(0); }
    00810
    00811       static const bool is_iec559 = true;
    00812       static const bool is_bounded = true;
    00813       static const bool is_modulo = true;
    00814
    00815       static const bool traps = __glibcpp_integral_traps;
    00816       static const bool tinyness_before = false;
    00817       static const float_round_style round_style = round_toward_zero;
    00818     };
    00819
    00820   template<>
    00821     struct numeric_limits<unsigned long long>
    00822     {
    00823       static const bool is_specialized = true;
    00824
    00825       static unsigned long long min() throw()
    00826       { return 0; }
    00827       static unsigned long long max() throw()
    00828       { return __LONG_LONG_MAX__ * 2ULL + 1; }
    00829
    00830       static const int digits = __glibcpp_digits (unsigned long long);
    00831       static const int digits10 = __glibcpp_digits10 (unsigned long long);
    00832       static const bool is_signed = false;
    00833       static const bool is_integer = true;
    00834       static const bool is_exact = true;
    00835       static const int radix = 2;
    00836       static unsigned long long epsilon() throw()
    00837       { return 0; }
    00838       static unsigned long long round_error() throw()
    00839       { return 0; }
    00840
    00841       static const int min_exponent = 0;
    00842       static const int min_exponent10 = 0;
    00843       static const int max_exponent = 0;
    00844       static const int max_exponent10 = 0;
    00845
    00846       static const bool has_infinity = false;
    00847       static const bool has_quiet_NaN = false;
    00848       static const bool has_signaling_NaN = false;
    00849       static const float_denorm_style has_denorm = denorm_absent;
    00850       static const bool has_denorm_loss = false;
    00851
    00852       static unsigned long long infinity() throw()
    00853       { return static_cast<unsigned long long>(0); }
    00854       static unsigned long long quiet_NaN() throw()
    00855       { return static_cast<unsigned long long>(0); }
    00856       static unsigned long long signaling_NaN() throw()
    00857       { return static_cast<unsigned long long>(0); }
    00858       static unsigned long long denorm_min() throw()
    00859       { return static_cast<unsigned long long>(0); }
    00860
    00861       static const bool is_iec559 = true;
    00862       static const bool is_bounded = true;
    00863       static const bool is_modulo = true;
    00864
    00865       static const bool traps = __glibcpp_integral_traps;
    00866       static const bool tinyness_before = false;
    00867       static const float_round_style round_style = round_toward_zero;
    00868     };
    00869
    00870   template<>
    00871     struct numeric_limits<float>
    00872     {
    00873       static const bool is_specialized = true;
    00874
    00875       static float min() throw()
    00876       { return __FLT_MIN__; }
    00877       static float max() throw()
    00878       { return __FLT_MAX__; }
    00879
    00880       static const int digits = __FLT_MANT_DIG__;
    00881       static const int digits10 = __FLT_DIG__;
    00882       static const bool is_signed = true;
    00883       static const bool is_integer = false;
    00884       static const bool is_exact = false;
    00885       static const int radix = __FLT_RADIX__;
    00886       static float epsilon() throw()
    00887       { return __FLT_EPSILON__; }
    00888       static float round_error() throw()
    00889       { return 0.5F; }
    00890
    00891       static const int min_exponent = __FLT_MIN_EXP__;
    00892       static const int min_exponent10 = __FLT_MIN_10_EXP__;
    00893       static const int max_exponent = __FLT_MAX_EXP__;
    00894       static const int max_exponent10 = __FLT_MAX_10_EXP__;
    00895
    00896       static const bool has_infinity
    00897     = __builtin_huge_valf () / 2 == __builtin_huge_valf ();
    00898       static const bool has_quiet_NaN
    00899     = __builtin_nanf ("") != __builtin_nanf ("");
    00900       static const bool has_signaling_NaN = has_quiet_NaN;
    00901       static const float_denorm_style has_denorm
    00902     = __FLT_DENORM_MIN__ ? denorm_present : denorm_absent;
    00903       static const bool has_denorm_loss = __glibcpp_float_has_denorm_loss;
    00904
    00905       static float infinity() throw()
    00906       { return __builtin_huge_valf (); }
    00907       static float quiet_NaN() throw()
    00908       { return __builtin_nanf (""); }
    00909       static float signaling_NaN() throw()
    00910       { return __builtin_nansf (""); }
    00911       static float denorm_min() throw()
    00912       { return __FLT_DENORM_MIN__; }
    00913
    00914       static const bool is_iec559
    00915     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
    00916       static const bool is_bounded = true;
    00917       static const bool is_modulo = false;
    00918
    00919       static const bool traps = __glibcpp_float_traps;
    00920       static const bool tinyness_before = __glibcpp_float_tinyness_before;
    00921       static const float_round_style round_style = round_to_nearest;
    00922     };
    00923
    00924 #undef __glibcpp_float_has_denorm_loss
    00925 #undef __glibcpp_float_traps
    00926 #undef __glibcpp_float_tinyness_before
    00927
    00928   template<>
    00929     struct numeric_limits<double>
    00930     {
    00931       static const bool is_specialized = true;
    00932
    00933       static double min() throw()
    00934       { return __DBL_MIN__; }
    00935       static double max() throw()
    00936       { return __DBL_MAX__; }
    00937
    00938       static const int digits = __DBL_MANT_DIG__;
    00939       static const int digits10 = __DBL_DIG__;
    00940       static const bool is_signed = true;
    00941       static const bool is_integer = false;
    00942       static const bool is_exact = false;
    00943       static const int radix = __FLT_RADIX__;
    00944       static double epsilon() throw()
    00945       { return __DBL_EPSILON__; }
    00946       static double round_error() throw()
    00947       { return 0.5; }
    00948
    00949       static const int min_exponent = __DBL_MIN_EXP__;
    00950       static const int min_exponent10 = __DBL_MIN_10_EXP__;
    00951       static const int max_exponent = __DBL_MAX_EXP__;
    00952       static const int max_exponent10 = __DBL_MAX_10_EXP__;
    00953
    00954       static const bool has_infinity
    00955     = __builtin_huge_val () / 2 == __builtin_huge_val ();
    00956       static const bool has_quiet_NaN
    00957     = __builtin_nan ("") != __builtin_nan ("");
    00958       static const bool has_signaling_NaN = has_quiet_NaN;
    00959       static const float_denorm_style has_denorm
    00960     = __DBL_DENORM_MIN__ ? denorm_present : denorm_absent;
    00961       static const bool has_denorm_loss = __glibcpp_double_has_denorm_loss;
    00962
    00963       static double infinity() throw()
    00964       { return __builtin_huge_val(); }
    00965       static double quiet_NaN() throw()
    00966       { return __builtin_nan (""); }
    00967       static double signaling_NaN() throw()
    00968       { return __builtin_nans (""); }
    00969       static double denorm_min() throw()
    00970       { return __DBL_DENORM_MIN__; }
    00971
    00972       static const bool is_iec559
    00973     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
    00974       static const bool is_bounded = true;
    00975       static const bool is_modulo = false;
    00976
    00977       static const bool traps = __glibcpp_double_traps;
    00978       static const bool tinyness_before = __glibcpp_double_tinyness_before;
    00979       static const float_round_style round_style = round_to_nearest;
    00980     };
    00981
    00982 #undef __glibcpp_double_has_denorm_loss
    00983 #undef __glibcpp_double_traps
    00984 #undef __glibcpp_double_tinyness_before
    00985
    00986   template<>
    00987     struct numeric_limits<long double>
    00988     {
    00989       static const bool is_specialized = true;
    00990
    00991       static long double min() throw()
    00992       { return __LDBL_MIN__; }
    00993       static long double max() throw()
    00994       { return __LDBL_MAX__; }
    00995
    00996       static const int digits = __LDBL_MANT_DIG__;
    00997       static const int digits10 = __LDBL_DIG__;
    00998       static const bool is_signed = true;
    00999       static const bool is_integer = false;
    01000       static const bool is_exact = false;
    01001       static const int radix = __FLT_RADIX__;
    01002       static long double epsilon() throw()
    01003       { return __LDBL_EPSILON__; }
    01004       static long double round_error() throw()
    01005       { return 0.5L; }
    01006
    01007       static const int min_exponent = __LDBL_MIN_EXP__;
    01008       static const int min_exponent10 = __LDBL_MIN_10_EXP__;
    01009       static const int max_exponent = __LDBL_MAX_EXP__;
    01010       static const int max_exponent10 = __LDBL_MAX_10_EXP__;
    01011
    01012       static const bool has_infinity
    01013     = __builtin_huge_vall () / 2 == __builtin_huge_vall ();
    01014       static const bool has_quiet_NaN
    01015     = __builtin_nanl ("") != __builtin_nanl ("");
    01016       static const bool has_signaling_NaN = has_quiet_NaN;
    01017       static const float_denorm_style has_denorm
    01018     = __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent;
    01019       static const bool has_denorm_loss
    01020     = __glibcpp_long_double_has_denorm_loss;
    01021
    01022       static long double infinity() throw()
    01023       { return __builtin_huge_vall (); }
    01024       static long double quiet_NaN() throw()
    01025       { return __builtin_nanl (""); }
    01026       static long double signaling_NaN() throw()
    01027       { return __builtin_nansl (""); }
    01028       static long double denorm_min() throw()
    01029       { return __LDBL_DENORM_MIN__; }
    01030
    01031       static const bool is_iec559
    01032     = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
    01033       static const bool is_bounded = true;
    01034       static const bool is_modulo = false;
    01035
    01036       static const bool traps = __glibcpp_long_double_traps;
    01037       static const bool tinyness_before = __glibcpp_long_double_tinyness_before;
    01038       static const float_round_style round_style = round_to_nearest;
    01039     };
    01040
    01041 #undef __glibcpp_long_double_has_denorm_loss
    01042 #undef __glibcpp_long_double_traps
    01043 #undef __glibcpp_long_double_tinyness_before
    01044
    01045 } // namespace std
    01046
    01047 #undef __glibcpp_signed
    01048 #undef __glibcpp_min
    01049 #undef __glibcpp_max
    01050 #undef __glibcpp_digits
    01051 #undef __glibcpp_digits10
    01052
    01053 #endif // _CPP_NUMERIC_LIMITS