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