1 // The template and inlines for the numeric_limits classes. -*- C++ -*-
2 
3 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
11 
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING.  If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
21 
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction.  Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License.  This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30 
31 /** @file limits
32  *  This is a Standard C++ Library header.
33  */
34 
35 // Note: this is not a conforming implementation.
36 // Written by Gabriel Dos Reis <gdr@codesourcery.com>
37 
38 //
39 // ISO 14882:1998
40 // 18.2.1
41 //
42 
43 #ifndef _GLIBCXX_NUMERIC_LIMITS
44 #define _GLIBCXX_NUMERIC_LIMITS 1
45 
46 #pragma GCC system_header
47 
48 #include <bits/c++config.h>
49 
50 //
51 // The numeric_limits<> traits document implementation-defined aspects
52 // of fundamental arithmetic data types (integers and floating points).
53 // From Standard C++ point of view, there are 13 such types:
54 //   * integers
55 //         bool						        (1)
56 //         char, signed char, unsigned char			(3)
57 //         short, unsigned short				(2)
58 //         int, unsigned					(2)
59 //         long, unsigned long					(2)
60 //
61 //   * floating points
62 //         float						(1)
63 //         double						(1)
64 //         long double						(1)
65 //
66 // GNU C++ undertstands (where supported by the host C-library)
67 //   * integer
68 //         long long, unsigned long long			(2)
69 //
70 // which brings us to 15 fundamental arithmetic data types in GNU C++.
71 //
72 //
73 // Since a numeric_limits<> is a bit tricky to get right, we rely on
74 // an interface composed of macros which should be defined in config/os
75 // or config/cpu when they differ from the generic (read arbitrary)
76 // definitions given here.
77 //
78 
79 // These values can be overridden in the target configuration file.
80 // The default values are appropriate for many 32-bit targets.
81 
82 // GCC only intrinsicly supports modulo integral types.  The only remaining
83 // integral exceptional values is division by zero.  Only targets that do not
84 // signal division by zero in some "hard to ignore" way should use false.
85 #ifndef __glibcxx_integral_traps
86 # define __glibcxx_integral_traps true
87 #endif
88 
89 // float
90 //
91 
92 // Default values.  Should be overriden in configuration files if necessary.
93 
94 #ifndef __glibcxx_float_has_denorm_loss
95 #  define __glibcxx_float_has_denorm_loss false
96 #endif
97 #ifndef __glibcxx_float_traps
98 #  define __glibcxx_float_traps false
99 #endif
100 #ifndef __glibcxx_float_tinyness_before
101 #  define __glibcxx_float_tinyness_before false
102 #endif
103 
104 // double
105 
106 // Default values.  Should be overriden in configuration files if necessary.
107 
108 #ifndef __glibcxx_double_has_denorm_loss
109 #  define __glibcxx_double_has_denorm_loss false
110 #endif
111 #ifndef __glibcxx_double_traps
112 #  define __glibcxx_double_traps false
113 #endif
114 #ifndef __glibcxx_double_tinyness_before
115 #  define __glibcxx_double_tinyness_before false
116 #endif
117 
118 // long double
119 
120 // Default values.  Should be overriden in configuration files if necessary.
121 
122 #ifndef __glibcxx_long_double_has_denorm_loss
123 #  define __glibcxx_long_double_has_denorm_loss false
124 #endif
125 #ifndef __glibcxx_long_double_traps
126 #  define __glibcxx_long_double_traps false
127 #endif
128 #ifndef __glibcxx_long_double_tinyness_before
129 #  define __glibcxx_long_double_tinyness_before false
130 #endif
131 
132 // You should not need to define any macros below this point.
133 
134 #define __glibcxx_signed(T)	((T)(-1) < 0)
135 
136 #define __glibcxx_min(T) \
137   (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
138 
139 #define __glibcxx_max(T) \
140   (__glibcxx_signed (T) ? \
141       (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
142 
143 
144 #define __glibcxx_digits(T) \
145   (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
146 
147 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
148 #define __glibcxx_digits10(T) \
149   (__glibcxx_digits (T) * 643 / 2136)
150 
151 
152 _GLIBCXX_BEGIN_NAMESPACE(std)
153 
154   /**
155    *  @brief Describes the rounding style for floating-point types.
156    *
157    *  This is used in the std::numeric_limits class.
158   */
159   enum float_round_style
160   {
161     round_indeterminate       = -1,    ///< Self-explanatory.
162     round_toward_zero         = 0,     ///< Self-explanatory.
163     round_to_nearest          = 1,     ///< To the nearest representable value.
164     round_toward_infinity     = 2,     ///< Self-explanatory.
165     round_toward_neg_infinity = 3      ///< Self-explanatory.
166   };
167 
168   /**
169    *  @brief Describes the denormalization for floating-point types.
170    *
171    *  These values represent the presence or absence of a variable number
172    *  of exponent bits.  This type is used in the std::numeric_limits class.
173   */
174   enum float_denorm_style
175   {
176     /// Indeterminate at compile time whether denormalized values are allowed.
177     denorm_indeterminate = -1,
178     /// The type does not allow denormalized values.
179     denorm_absent        = 0,
180     /// The type allows denormalized values.
181     denorm_present       = 1
182   };
183 
184   /**
185    *  @brief Part of std::numeric_limits.
186    *
187    *  The @c static @c const members are usable as integral constant
188    *  expressions.
189    *
190    *  @note This is a seperate class for purposes of efficiency; you
191    *        should only access these members as part of an instantiation
192    *        of the std::numeric_limits class.
193   */
194   struct __numeric_limits_base
195   {
196     /** This will be true for all fundamental types (which have
197         specializations), and false for everything else.  */
198     static const bool is_specialized = false;
199 
200     /** The number of @c radix digits that be represented without change:  for
201         integer types, the number of non-sign bits in the mantissa; for
202         floating types, the number of @c radix digits in the mantissa.  */
203     static const int digits = 0;
204     /** The number of base 10 digits that can be represented without change. */
205     static const int digits10 = 0;
206     /** True if the type is signed.  */
207     static const bool is_signed = false;
208     /** True if the type is integer.
209      *  @if maint
210      *  Is this supposed to be "if the type is integral"?
211      *  @endif
212     */
213     static const bool is_integer = false;
214     /** True if the type uses an exact representation.  "All integer types are
215         exact, but not all exact types are integer.  For example, rational and
216         fixed-exponent representations are exact but not integer."
217         [18.2.1.2]/15  */
218     static const bool is_exact = false;
219     /** For integer types, specifies the base of the representation.  For
220         floating types, specifies the base of the exponent representation.  */
221     static const int radix = 0;
222 
223     /** The minimum negative integer such that @c radix raised to the power of
224         (one less than that integer) is a normalized floating point number.  */
225     static const int min_exponent = 0;
226     /** The minimum negative integer such that 10 raised to that power is in
227         the range of normalized floating point numbers.  */
228     static const int min_exponent10 = 0;
229     /** The maximum positive integer such that @c radix raised to the power of
230         (one less than that integer) is a representable finite floating point
231 	number.  */
232     static const int max_exponent = 0;
233     /** The maximum positive integer such that 10 raised to that power is in
234         the range of representable finite floating point numbers.  */
235     static const int max_exponent10 = 0;
236 
237     /** True if the type has a representation for positive infinity.  */
238     static const bool has_infinity = false;
239     /** True if the type has a representation for a quiet (non-signaling)
240         "Not a Number."  */
241     static const bool has_quiet_NaN = false;
242     /** True if the type has a representation for a signaling
243         "Not a Number."  */
244     static const bool has_signaling_NaN = false;
245     /** See std::float_denorm_style for more information.  */
246     static const float_denorm_style has_denorm = denorm_absent;
247     /** "True if loss of accuracy is detected as a denormalization loss,
248         rather than as an inexact result." [18.2.1.2]/42  */
249     static const bool has_denorm_loss = false;
250 
251     /** True if-and-only-if the type adheres to the IEC 559 standard, also
252         known as IEEE 754.  (Only makes sense for floating point types.)  */
253     static const bool is_iec559 = false;
254     /** "True if the set of values representable by the type is finite.   All
255         built-in types are bounded, this member would be false for arbitrary
256 	precision types." [18.2.1.2]/54  */
257     static const bool is_bounded = false;
258     /** True if the type is @e modulo, that is, if it is possible to add two
259         positive numbers and have a result that wraps around to a third number
260         that is less.  Typically false for floating types, true for unsigned
261         integers, and true for signed integers.  */
262     static const bool is_modulo = false;
263 
264     /** True if trapping is implemented for this type.  */
265     static const bool traps = false;
266     /** True if tinyness is detected before rounding.  (see IEC 559)  */
267     static const bool tinyness_before = false;
268     /** See std::float_round_style for more information.  This is only
269         meaningful for floating types; integer types will all be
270 	round_toward_zero.  */
271     static const float_round_style round_style = round_toward_zero;
272   };
273 
274   /**
275    *  @brief Properties of fundamental types.
276    *
277    *  This class allows a program to obtain information about the
278    *  representation of a fundamental type on a given platform.  For
279    *  non-fundamental types, the functions will return 0 and the data
280    *  members will all be @c false.
281    *
282    *  @if maint
283    *  _GLIBCXX_RESOLVE_LIB_DEFECTS:  DRs 201 and 184 (hi Gaby!) are
284    *  noted, but not incorporated in this documented (yet).
285    *  @endif
286   */
287   template<typename _Tp>
288     struct numeric_limits : public __numeric_limits_base
289     {
290       /** The minimum finite value, or for floating types with
291           denormalization, the minimum positive normalized value.  */
minnumeric_limits292       static _Tp min() throw() { return static_cast<_Tp>(0); }
293       /** The maximum finite value.  */
maxnumeric_limits294       static _Tp max() throw() { return static_cast<_Tp>(0); }
295       /** The @e machine @e epsilon:  the difference between 1 and the least
296           value greater than 1 that is representable.  */
epsilonnumeric_limits297       static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
298       /** The maximum rounding error measurement (see LIA-1).  */
round_errornumeric_limits299       static _Tp round_error() throw() { return static_cast<_Tp>(0); }
300       /** The representation of positive infinity, if @c has_infinity.  */
infinitynumeric_limits301       static _Tp infinity() throw()  { return static_cast<_Tp>(0); }
302       /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */
quiet_NaNnumeric_limits303       static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
304       /** The representation of a signaling "Not a Number," if
305           @c has_signaling_NaN. */
signaling_NaNnumeric_limits306       static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
307       /** The minimum positive denormalized value.  For types where
308           @c has_denorm is false, this is the minimum positive normalized
309 	  value.  */
denorm_minnumeric_limits310       static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
311     };
312 
313   // Now there follow 15 explicit specializations.  Yes, 15.  Make sure
314   // you get the count right.
315 
316   /// numeric_limits<bool> specialization.
317   template<>
318     struct numeric_limits<bool>
319     {
320       static const bool is_specialized = true;
321 
322       static bool min() throw()
323       { return false; }
324       static bool max() throw()
325       { return true; }
326 
327       static const int digits = 1;
328       static const int digits10 = 0;
329       static const bool is_signed = false;
330       static const bool is_integer = true;
331       static const bool is_exact = true;
332       static const int radix = 2;
333       static bool epsilon() throw()
334       { return false; }
335       static bool round_error() throw()
336       { return false; }
337 
338       static const int min_exponent = 0;
339       static const int min_exponent10 = 0;
340       static const int max_exponent = 0;
341       static const int max_exponent10 = 0;
342 
343       static const bool has_infinity = false;
344       static const bool has_quiet_NaN = false;
345       static const bool has_signaling_NaN = false;
346       static const float_denorm_style has_denorm = denorm_absent;
347       static const bool has_denorm_loss = false;
348 
349       static bool infinity() throw()
350       { return false; }
351       static bool quiet_NaN() throw()
352       { return false; }
353       static bool signaling_NaN() throw()
354       { return false; }
355       static bool denorm_min() throw()
356       { return false; }
357 
358       static const bool is_iec559 = false;
359       static const bool is_bounded = true;
360       static const bool is_modulo = false;
361 
362       // It is not clear what it means for a boolean type to trap.
363       // This is a DR on the LWG issue list.  Here, I use integer
364       // promotion semantics.
365       static const bool traps = __glibcxx_integral_traps;
366       static const bool tinyness_before = false;
367       static const float_round_style round_style = round_toward_zero;
368     };
369 
370   /// numeric_limits<signed char> specialization.
371   template<>
372     struct numeric_limits<signed char>
373     {
374       static const bool is_specialized = true;
375 
376       static signed char min() throw()
377       { return -__SCHAR_MAX__ - 1; }
378       static signed char max() throw()
379       { return __SCHAR_MAX__; }
380 
381       static const int digits = __glibcxx_digits (signed char);
382       static const int digits10 = __glibcxx_digits10 (signed char);
383       static const bool is_signed = true;
384       static const bool is_integer = true;
385       static const bool is_exact = true;
386       static const int radix = 2;
387       static signed char epsilon() throw()
388       { return 0; }
389       static signed char round_error() throw()
390       { return 0; }
391 
392       static const int min_exponent = 0;
393       static const int min_exponent10 = 0;
394       static const int max_exponent = 0;
395       static const int max_exponent10 = 0;
396 
397       static const bool has_infinity = false;
398       static const bool has_quiet_NaN = false;
399       static const bool has_signaling_NaN = false;
400       static const float_denorm_style has_denorm = denorm_absent;
401       static const bool has_denorm_loss = false;
402 
403       static signed char infinity() throw()
404       { return static_cast<signed char>(0); }
405       static signed char quiet_NaN() throw()
406       { return static_cast<signed char>(0); }
407       static signed char signaling_NaN() throw()
408       { return static_cast<signed char>(0); }
409       static signed char denorm_min() throw()
410       { return static_cast<signed char>(0); }
411 
412       static const bool is_iec559 = false;
413       static const bool is_bounded = true;
414       static const bool is_modulo = true;
415 
416       static const bool traps = __glibcxx_integral_traps;
417       static const bool tinyness_before = false;
418       static const float_round_style round_style = round_toward_zero;
419     };
420 
421   /// numeric_limits<unsigned char> specialization.
422   template<>
423     struct numeric_limits<unsigned char>
424     {
425       static const bool is_specialized = true;
426 
427       static unsigned char min() throw()
428       { return 0; }
429       static unsigned char max() throw()
430       { return __SCHAR_MAX__ * 2U + 1; }
431 
432       static const int digits = __glibcxx_digits (unsigned char);
433       static const int digits10 = __glibcxx_digits10 (unsigned char);
434       static const bool is_signed = false;
435       static const bool is_integer = true;
436       static const bool is_exact = true;
437       static const int radix = 2;
438       static unsigned char epsilon() throw()
439       { return 0; }
440       static unsigned char round_error() throw()
441       { return 0; }
442 
443       static const int min_exponent = 0;
444       static const int min_exponent10 = 0;
445       static const int max_exponent = 0;
446       static const int max_exponent10 = 0;
447 
448       static const bool has_infinity = false;
449       static const bool has_quiet_NaN = false;
450       static const bool has_signaling_NaN = false;
451       static const float_denorm_style has_denorm = denorm_absent;
452       static const bool has_denorm_loss = false;
453 
454       static unsigned char infinity() throw()
455       { return static_cast<unsigned char>(0); }
456       static unsigned char quiet_NaN() throw()
457       { return static_cast<unsigned char>(0); }
458       static unsigned char signaling_NaN() throw()
459       { return static_cast<unsigned char>(0); }
460       static unsigned char denorm_min() throw()
461       { return static_cast<unsigned char>(0); }
462 
463       static const bool is_iec559 = false;
464       static const bool is_bounded = true;
465       static const bool is_modulo = true;
466 
467       static const bool traps = __glibcxx_integral_traps;
468       static const bool tinyness_before = false;
469       static const float_round_style round_style = round_toward_zero;
470     };
471 
472   /// numeric_limits<char> specialization.
473   template<>
474     struct numeric_limits<char>
475     {
476       static const bool is_specialized = true;
477 
478       static char min() throw()
479       { return __glibcxx_signed(char) ?
480 	    numeric_limits<signed char>::min() :
481 	    numeric_limits<unsigned char>::min(); }
482       static char max() throw()
483       { return __glibcxx_signed(char) ?
484 	    numeric_limits<signed char>::max() :
485 	    numeric_limits<unsigned char>::max(); }
486 
487       static const int digits = __glibcxx_digits (char);
488       static const int digits10 = __glibcxx_digits10 (char);
489       static const bool is_signed = __glibcxx_signed (char);
490       static const bool is_integer = true;
491       static const bool is_exact = true;
492       static const int radix = 2;
493       static char epsilon() throw()
494       { return 0; }
495       static char round_error() throw()
496       { return 0; }
497 
498       static const int min_exponent = 0;
499       static const int min_exponent10 = 0;
500       static const int max_exponent = 0;
501       static const int max_exponent10 = 0;
502 
503       static const bool has_infinity = false;
504       static const bool has_quiet_NaN = false;
505       static const bool has_signaling_NaN = false;
506       static const float_denorm_style has_denorm = denorm_absent;
507       static const bool has_denorm_loss = false;
508 
509       static char infinity() throw()
510       { return char(); }
511       static char quiet_NaN() throw()
512       { return char(); }
513       static char signaling_NaN() throw()
514       { return char(); }
515       static char denorm_min() throw()
516       { return static_cast<char>(0); }
517 
518       static const bool is_iec559 = false;
519       static const bool is_bounded = true;
520       static const bool is_modulo = true;
521 
522       static const bool traps = __glibcxx_integral_traps;
523       static const bool tinyness_before = false;
524       static const float_round_style round_style = round_toward_zero;
525     };
526 
527   /// numeric_limits<wchar_t> specialization.
528   template<>
529     struct numeric_limits<wchar_t>
530     {
531       static const bool is_specialized = true;
532 
533       static wchar_t min() throw()
534       { return __glibcxx_min (wchar_t); }
535       static wchar_t max() throw()
536       { return __glibcxx_max (wchar_t); }
537 
538       static const int digits = __glibcxx_digits (wchar_t);
539       static const int digits10 = __glibcxx_digits10 (wchar_t);
540       static const bool is_signed = __glibcxx_signed (wchar_t);
541       static const bool is_integer = true;
542       static const bool is_exact = true;
543       static const int radix = 2;
544       static wchar_t epsilon() throw()
545       { return 0; }
546       static wchar_t round_error() throw()
547       { return 0; }
548 
549       static const int min_exponent = 0;
550       static const int min_exponent10 = 0;
551       static const int max_exponent = 0;
552       static const int max_exponent10 = 0;
553 
554       static const bool has_infinity = false;
555       static const bool has_quiet_NaN = false;
556       static const bool has_signaling_NaN = false;
557       static const float_denorm_style has_denorm = denorm_absent;
558       static const bool has_denorm_loss = false;
559 
560       static wchar_t infinity() throw()
561       { return wchar_t(); }
562       static wchar_t quiet_NaN() throw()
563       { return wchar_t(); }
564       static wchar_t signaling_NaN() throw()
565       { return wchar_t(); }
566       static wchar_t denorm_min() throw()
567       { return wchar_t(); }
568 
569       static const bool is_iec559 = false;
570       static const bool is_bounded = true;
571       static const bool is_modulo = true;
572 
573       static const bool traps = __glibcxx_integral_traps;
574       static const bool tinyness_before = false;
575       static const float_round_style round_style = round_toward_zero;
576     };
577 
578   /// numeric_limits<short> specialization.
579   template<>
580     struct numeric_limits<short>
581     {
582       static const bool is_specialized = true;
583 
584       static short min() throw()
585       { return -__SHRT_MAX__ - 1; }
586       static short max() throw()
587       { return __SHRT_MAX__; }
588 
589       static const int digits = __glibcxx_digits (short);
590       static const int digits10 = __glibcxx_digits10 (short);
591       static const bool is_signed = true;
592       static const bool is_integer = true;
593       static const bool is_exact = true;
594       static const int radix = 2;
595       static short epsilon() throw()
596       { return 0; }
597       static short round_error() throw()
598       { return 0; }
599 
600       static const int min_exponent = 0;
601       static const int min_exponent10 = 0;
602       static const int max_exponent = 0;
603       static const int max_exponent10 = 0;
604 
605       static const bool has_infinity = false;
606       static const bool has_quiet_NaN = false;
607       static const bool has_signaling_NaN = false;
608       static const float_denorm_style has_denorm = denorm_absent;
609       static const bool has_denorm_loss = false;
610 
611       static short infinity() throw()
612       { return short(); }
613       static short quiet_NaN() throw()
614       { return short(); }
615       static short signaling_NaN() throw()
616       { return short(); }
617       static short denorm_min() throw()
618       { return short(); }
619 
620       static const bool is_iec559 = false;
621       static const bool is_bounded = true;
622       static const bool is_modulo = true;
623 
624       static const bool traps = __glibcxx_integral_traps;
625       static const bool tinyness_before = false;
626       static const float_round_style round_style = round_toward_zero;
627     };
628 
629   /// numeric_limits<unsigned short> specialization.
630   template<>
631     struct numeric_limits<unsigned short>
632     {
633       static const bool is_specialized = true;
634 
635       static unsigned short min() throw()
636       { return 0; }
637       static unsigned short max() throw()
638       { return __SHRT_MAX__ * 2U + 1; }
639 
640       static const int digits = __glibcxx_digits (unsigned short);
641       static const int digits10 = __glibcxx_digits10 (unsigned short);
642       static const bool is_signed = false;
643       static const bool is_integer = true;
644       static const bool is_exact = true;
645       static const int radix = 2;
646       static unsigned short epsilon() throw()
647       { return 0; }
648       static unsigned short round_error() throw()
649       { return 0; }
650 
651       static const int min_exponent = 0;
652       static const int min_exponent10 = 0;
653       static const int max_exponent = 0;
654       static const int max_exponent10 = 0;
655 
656       static const bool has_infinity = false;
657       static const bool has_quiet_NaN = false;
658       static const bool has_signaling_NaN = false;
659       static const float_denorm_style has_denorm = denorm_absent;
660       static const bool has_denorm_loss = false;
661 
662       static unsigned short infinity() throw()
663       { return static_cast<unsigned short>(0); }
664       static unsigned short quiet_NaN() throw()
665       { return static_cast<unsigned short>(0); }
666       static unsigned short signaling_NaN() throw()
667       { return static_cast<unsigned short>(0); }
668       static unsigned short denorm_min() throw()
669       { return static_cast<unsigned short>(0); }
670 
671       static const bool is_iec559 = false;
672       static const bool is_bounded = true;
673       static const bool is_modulo = true;
674 
675       static const bool traps = __glibcxx_integral_traps;
676       static const bool tinyness_before = false;
677       static const float_round_style round_style = round_toward_zero;
678     };
679 
680   /// numeric_limits<int> specialization.
681   template<>
682     struct numeric_limits<int>
683     {
684       static const bool is_specialized = true;
685 
686       static int min() throw()
687       { return -__INT_MAX__ - 1; }
688       static int max() throw()
689       { return __INT_MAX__; }
690 
691       static const int digits = __glibcxx_digits (int);
692       static const int digits10 = __glibcxx_digits10 (int);
693       static const bool is_signed = true;
694       static const bool is_integer = true;
695       static const bool is_exact = true;
696       static const int radix = 2;
697       static int epsilon() throw()
698       { return 0; }
699       static int round_error() throw()
700       { return 0; }
701 
702       static const int min_exponent = 0;
703       static const int min_exponent10 = 0;
704       static const int max_exponent = 0;
705       static const int max_exponent10 = 0;
706 
707       static const bool has_infinity = false;
708       static const bool has_quiet_NaN = false;
709       static const bool has_signaling_NaN = false;
710       static const float_denorm_style has_denorm = denorm_absent;
711       static const bool has_denorm_loss = false;
712 
713       static int infinity() throw()
714       { return static_cast<int>(0); }
715       static int quiet_NaN() throw()
716       { return static_cast<int>(0); }
717       static int signaling_NaN() throw()
718       { return static_cast<int>(0); }
719       static int denorm_min() throw()
720       { return static_cast<int>(0); }
721 
722       static const bool is_iec559 = false;
723       static const bool is_bounded = true;
724       static const bool is_modulo = true;
725 
726       static const bool traps = __glibcxx_integral_traps;
727       static const bool tinyness_before = false;
728       static const float_round_style round_style = round_toward_zero;
729     };
730 
731   /// numeric_limits<unsigned int> specialization.
732   template<>
733     struct numeric_limits<unsigned int>
734     {
735       static const bool is_specialized = true;
736 
737       static unsigned int min() throw()
738       { return 0; }
739       static unsigned int max() throw()
740       { return __INT_MAX__ * 2U + 1; }
741 
742       static const int digits = __glibcxx_digits (unsigned int);
743       static const int digits10 = __glibcxx_digits10 (unsigned int);
744       static const bool is_signed = false;
745       static const bool is_integer = true;
746       static const bool is_exact = true;
747       static const int radix = 2;
748       static unsigned int epsilon() throw()
749       { return 0; }
750       static unsigned int round_error() throw()
751       { return 0; }
752 
753       static const int min_exponent = 0;
754       static const int min_exponent10 = 0;
755       static const int max_exponent = 0;
756       static const int max_exponent10 = 0;
757 
758       static const bool has_infinity = false;
759       static const bool has_quiet_NaN = false;
760       static const bool has_signaling_NaN = false;
761       static const float_denorm_style has_denorm = denorm_absent;
762       static const bool has_denorm_loss = false;
763 
764       static unsigned int infinity() throw()
765       { return static_cast<unsigned int>(0); }
766       static unsigned int quiet_NaN() throw()
767       { return static_cast<unsigned int>(0); }
768       static unsigned int signaling_NaN() throw()
769       { return static_cast<unsigned int>(0); }
770       static unsigned int denorm_min() throw()
771       { return static_cast<unsigned int>(0); }
772 
773       static const bool is_iec559 = false;
774       static const bool is_bounded = true;
775       static const bool is_modulo = true;
776 
777       static const bool traps = __glibcxx_integral_traps;
778       static const bool tinyness_before = false;
779       static const float_round_style round_style = round_toward_zero;
780     };
781 
782   /// numeric_limits<long> specialization.
783   template<>
784     struct numeric_limits<long>
785     {
786       static const bool is_specialized = true;
787 
788       static long min() throw()
789       { return -__LONG_MAX__ - 1; }
790       static long max() throw()
791       { return __LONG_MAX__; }
792 
793       static const int digits = __glibcxx_digits (long);
794       static const int digits10 = __glibcxx_digits10 (long);
795       static const bool is_signed = true;
796       static const bool is_integer = true;
797       static const bool is_exact = true;
798       static const int radix = 2;
799       static long epsilon() throw()
800       { return 0; }
801       static long round_error() throw()
802       { return 0; }
803 
804       static const int min_exponent = 0;
805       static const int min_exponent10 = 0;
806       static const int max_exponent = 0;
807       static const int max_exponent10 = 0;
808 
809       static const bool has_infinity = false;
810       static const bool has_quiet_NaN = false;
811       static const bool has_signaling_NaN = false;
812       static const float_denorm_style has_denorm = denorm_absent;
813       static const bool has_denorm_loss = false;
814 
815       static long infinity() throw()
816       { return static_cast<long>(0); }
817       static long quiet_NaN() throw()
818       { return static_cast<long>(0); }
819       static long signaling_NaN() throw()
820       { return static_cast<long>(0); }
821       static long denorm_min() throw()
822       { return static_cast<long>(0); }
823 
824       static const bool is_iec559 = false;
825       static const bool is_bounded = true;
826       static const bool is_modulo = true;
827 
828       static const bool traps = __glibcxx_integral_traps;
829       static const bool tinyness_before = false;
830       static const float_round_style round_style = round_toward_zero;
831     };
832 
833   /// numeric_limits<unsigned long> specialization.
834   template<>
835     struct numeric_limits<unsigned long>
836     {
837       static const bool is_specialized = true;
838 
839       static unsigned long min() throw()
840       { return 0; }
841       static unsigned long max() throw()
842       { return __LONG_MAX__ * 2UL + 1; }
843 
844       static const int digits = __glibcxx_digits (unsigned long);
845       static const int digits10 = __glibcxx_digits10 (unsigned long);
846       static const bool is_signed = false;
847       static const bool is_integer = true;
848       static const bool is_exact = true;
849       static const int radix = 2;
850       static unsigned long epsilon() throw()
851       { return 0; }
852       static unsigned long round_error() throw()
853       { return 0; }
854 
855       static const int min_exponent = 0;
856       static const int min_exponent10 = 0;
857       static const int max_exponent = 0;
858       static const int max_exponent10 = 0;
859 
860       static const bool has_infinity = false;
861       static const bool has_quiet_NaN = false;
862       static const bool has_signaling_NaN = false;
863       static const float_denorm_style has_denorm = denorm_absent;
864       static const bool has_denorm_loss = false;
865 
866       static unsigned long infinity() throw()
867       { return static_cast<unsigned long>(0); }
868       static unsigned long quiet_NaN() throw()
869       { return static_cast<unsigned long>(0); }
870       static unsigned long signaling_NaN() throw()
871       { return static_cast<unsigned long>(0); }
872       static unsigned long denorm_min() throw()
873       { return static_cast<unsigned long>(0); }
874 
875       static const bool is_iec559 = false;
876       static const bool is_bounded = true;
877       static const bool is_modulo = true;
878 
879       static const bool traps = __glibcxx_integral_traps;
880       static const bool tinyness_before = false;
881       static const float_round_style round_style = round_toward_zero;
882     };
883 
884   /// numeric_limits<long long> specialization.
885   template<>
886     struct numeric_limits<long long>
887     {
888       static const bool is_specialized = true;
889 
890       static long long min() throw()
891       { return -__LONG_LONG_MAX__ - 1; }
892       static long long max() throw()
893       { return __LONG_LONG_MAX__; }
894 
895       static const int digits = __glibcxx_digits (long long);
896       static const int digits10 = __glibcxx_digits10 (long long);
897       static const bool is_signed = true;
898       static const bool is_integer = true;
899       static const bool is_exact = true;
900       static const int radix = 2;
901       static long long epsilon() throw()
902       { return 0; }
903       static long long round_error() throw()
904       { return 0; }
905 
906       static const int min_exponent = 0;
907       static const int min_exponent10 = 0;
908       static const int max_exponent = 0;
909       static const int max_exponent10 = 0;
910 
911       static const bool has_infinity = false;
912       static const bool has_quiet_NaN = false;
913       static const bool has_signaling_NaN = false;
914       static const float_denorm_style has_denorm = denorm_absent;
915       static const bool has_denorm_loss = false;
916 
917       static long long infinity() throw()
918       { return static_cast<long long>(0); }
919       static long long quiet_NaN() throw()
920       { return static_cast<long long>(0); }
921       static long long signaling_NaN() throw()
922       { return static_cast<long long>(0); }
923       static long long denorm_min() throw()
924       { return static_cast<long long>(0); }
925 
926       static const bool is_iec559 = false;
927       static const bool is_bounded = true;
928       static const bool is_modulo = true;
929 
930       static const bool traps = __glibcxx_integral_traps;
931       static const bool tinyness_before = false;
932       static const float_round_style round_style = round_toward_zero;
933     };
934 
935   /// numeric_limits<unsigned long long> specialization.
936   template<>
937     struct numeric_limits<unsigned long long>
938     {
939       static const bool is_specialized = true;
940 
941       static unsigned long long min() throw()
942       { return 0; }
943       static unsigned long long max() throw()
944       { return __LONG_LONG_MAX__ * 2ULL + 1; }
945 
946       static const int digits = __glibcxx_digits (unsigned long long);
947       static const int digits10 = __glibcxx_digits10 (unsigned long long);
948       static const bool is_signed = false;
949       static const bool is_integer = true;
950       static const bool is_exact = true;
951       static const int radix = 2;
952       static unsigned long long epsilon() throw()
953       { return 0; }
954       static unsigned long long round_error() throw()
955       { return 0; }
956 
957       static const int min_exponent = 0;
958       static const int min_exponent10 = 0;
959       static const int max_exponent = 0;
960       static const int max_exponent10 = 0;
961 
962       static const bool has_infinity = false;
963       static const bool has_quiet_NaN = false;
964       static const bool has_signaling_NaN = false;
965       static const float_denorm_style has_denorm = denorm_absent;
966       static const bool has_denorm_loss = false;
967 
968       static unsigned long long infinity() throw()
969       { return static_cast<unsigned long long>(0); }
970       static unsigned long long quiet_NaN() throw()
971       { return static_cast<unsigned long long>(0); }
972       static unsigned long long signaling_NaN() throw()
973       { return static_cast<unsigned long long>(0); }
974       static unsigned long long denorm_min() throw()
975       { return static_cast<unsigned long long>(0); }
976 
977       static const bool is_iec559 = false;
978       static const bool is_bounded = true;
979       static const bool is_modulo = true;
980 
981       static const bool traps = __glibcxx_integral_traps;
982       static const bool tinyness_before = false;
983       static const float_round_style round_style = round_toward_zero;
984     };
985 
986   /// numeric_limits<float> specialization.
987   template<>
988     struct numeric_limits<float>
989     {
990       static const bool is_specialized = true;
991 
992       static float min() throw()
993       { return __FLT_MIN__; }
994       static float max() throw()
995       { return __FLT_MAX__; }
996 
997       static const int digits = __FLT_MANT_DIG__;
998       static const int digits10 = __FLT_DIG__;
999       static const bool is_signed = true;
1000       static const bool is_integer = false;
1001       static const bool is_exact = false;
1002       static const int radix = __FLT_RADIX__;
1003       static float epsilon() throw()
1004       { return __FLT_EPSILON__; }
1005       static float round_error() throw()
1006       { return 0.5F; }
1007 
1008       static const int min_exponent = __FLT_MIN_EXP__;
1009       static const int min_exponent10 = __FLT_MIN_10_EXP__;
1010       static const int max_exponent = __FLT_MAX_EXP__;
1011       static const int max_exponent10 = __FLT_MAX_10_EXP__;
1012 
1013       static const bool has_infinity = __FLT_HAS_INFINITY__;
1014       static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
1015       static const bool has_signaling_NaN = has_quiet_NaN;
1016       static const float_denorm_style has_denorm
1017 	= bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
1018       static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
1019 
1020       static float infinity() throw()
1021       { return __builtin_huge_valf (); }
1022       static float quiet_NaN() throw()
1023       { return __builtin_nanf (""); }
1024       static float signaling_NaN() throw()
1025       { return __builtin_nansf (""); }
1026       static float denorm_min() throw()
1027       { return __FLT_DENORM_MIN__; }
1028 
1029       static const bool is_iec559
1030 	= has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1031       static const bool is_bounded = true;
1032       static const bool is_modulo = false;
1033 
1034       static const bool traps = __glibcxx_float_traps;
1035       static const bool tinyness_before = __glibcxx_float_tinyness_before;
1036       static const float_round_style round_style = round_to_nearest;
1037     };
1038 
1039 #undef __glibcxx_float_has_denorm_loss
1040 #undef __glibcxx_float_traps
1041 #undef __glibcxx_float_tinyness_before
1042 
1043   /// numeric_limits<double> specialization.
1044   template<>
1045     struct numeric_limits<double>
1046     {
1047       static const bool is_specialized = true;
1048 
1049       static double min() throw()
1050       { return __DBL_MIN__; }
1051       static double max() throw()
1052       { return __DBL_MAX__; }
1053 
1054       static const int digits = __DBL_MANT_DIG__;
1055       static const int digits10 = __DBL_DIG__;
1056       static const bool is_signed = true;
1057       static const bool is_integer = false;
1058       static const bool is_exact = false;
1059       static const int radix = __FLT_RADIX__;
1060       static double epsilon() throw()
1061       { return __DBL_EPSILON__; }
1062       static double round_error() throw()
1063       { return 0.5; }
1064 
1065       static const int min_exponent = __DBL_MIN_EXP__;
1066       static const int min_exponent10 = __DBL_MIN_10_EXP__;
1067       static const int max_exponent = __DBL_MAX_EXP__;
1068       static const int max_exponent10 = __DBL_MAX_10_EXP__;
1069 
1070       static const bool has_infinity = __DBL_HAS_INFINITY__;
1071       static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
1072       static const bool has_signaling_NaN = has_quiet_NaN;
1073       static const float_denorm_style has_denorm
1074 	= bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1075       static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
1076 
1077       static double infinity() throw()
1078       { return __builtin_huge_val(); }
1079       static double quiet_NaN() throw()
1080       { return __builtin_nan (""); }
1081       static double signaling_NaN() throw()
1082       { return __builtin_nans (""); }
1083       static double denorm_min() throw()
1084       { return __DBL_DENORM_MIN__; }
1085 
1086       static const bool is_iec559
1087 	= has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1088       static const bool is_bounded = true;
1089       static const bool is_modulo = false;
1090 
1091       static const bool traps = __glibcxx_double_traps;
1092       static const bool tinyness_before = __glibcxx_double_tinyness_before;
1093       static const float_round_style round_style = round_to_nearest;
1094     };
1095 
1096 #undef __glibcxx_double_has_denorm_loss
1097 #undef __glibcxx_double_traps
1098 #undef __glibcxx_double_tinyness_before
1099 
1100   /// numeric_limits<long double> specialization.
1101   template<>
1102     struct numeric_limits<long double>
1103     {
1104       static const bool is_specialized = true;
1105 
1106       static long double min() throw()
1107       { return __LDBL_MIN__; }
1108       static long double max() throw()
1109       { return __LDBL_MAX__; }
1110 
1111       static const int digits = __LDBL_MANT_DIG__;
1112       static const int digits10 = __LDBL_DIG__;
1113       static const bool is_signed = true;
1114       static const bool is_integer = false;
1115       static const bool is_exact = false;
1116       static const int radix = __FLT_RADIX__;
1117       static long double epsilon() throw()
1118       { return __LDBL_EPSILON__; }
1119       static long double round_error() throw()
1120       { return 0.5L; }
1121 
1122       static const int min_exponent = __LDBL_MIN_EXP__;
1123       static const int min_exponent10 = __LDBL_MIN_10_EXP__;
1124       static const int max_exponent = __LDBL_MAX_EXP__;
1125       static const int max_exponent10 = __LDBL_MAX_10_EXP__;
1126 
1127       static const bool has_infinity = __LDBL_HAS_INFINITY__;
1128       static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
1129       static const bool has_signaling_NaN = has_quiet_NaN;
1130       static const float_denorm_style has_denorm
1131 	= bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1132       static const bool has_denorm_loss
1133 	= __glibcxx_long_double_has_denorm_loss;
1134 
1135       static long double infinity() throw()
1136       { return __builtin_huge_vall (); }
1137       static long double quiet_NaN() throw()
1138       { return __builtin_nanl (""); }
1139       static long double signaling_NaN() throw()
1140       { return __builtin_nansl (""); }
1141       static long double denorm_min() throw()
1142       { return __LDBL_DENORM_MIN__; }
1143 
1144       static const bool is_iec559
1145 	= has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1146       static const bool is_bounded = true;
1147       static const bool is_modulo = false;
1148 
1149       static const bool traps = __glibcxx_long_double_traps;
1150       static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
1151       static const float_round_style round_style = round_to_nearest;
1152     };
1153 
1154 #undef __glibcxx_long_double_has_denorm_loss
1155 #undef __glibcxx_long_double_traps
1156 #undef __glibcxx_long_double_tinyness_before
1157 
1158 _GLIBCXX_END_NAMESPACE
1159 
1160 #undef __glibcxx_signed
1161 #undef __glibcxx_min
1162 #undef __glibcxx_max
1163 #undef __glibcxx_digits
1164 #undef __glibcxx_digits10
1165 
1166 #endif // _GLIBCXX_NUMERIC_LIMITS
1167