1 // The template and inlines for the numeric_limits classes. -*- C++ -*-
3 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 // 2008, 2009, 2010 Free Software Foundation, Inc.
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 3, or (at your option)
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.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
27 * This is a Standard C++ Library header.
30 // Note: this is not a conforming implementation.
31 // Written by Gabriel Dos Reis <gdr@codesourcery.com>
38 #ifndef _GLIBCXX_NUMERIC_LIMITS
39 #define _GLIBCXX_NUMERIC_LIMITS 1
41 #pragma GCC system_header
43 #include <bits/c++config.h>
46 // The numeric_limits<> traits document implementation-defined aspects
47 // of fundamental arithmetic data types (integers and floating points).
48 // From Standard C++ point of view, there are 14 such types:
51 // char, signed char, unsigned char, wchar_t (4)
52 // short, unsigned short (2)
54 // long, unsigned long (2)
61 // GNU C++ understands (where supported by the host C-library)
63 // long long, unsigned long long (2)
65 // which brings us to 16 fundamental arithmetic data types in GNU C++.
68 // Since a numeric_limits<> is a bit tricky to get right, we rely on
69 // an interface composed of macros which should be defined in config/os
70 // or config/cpu when they differ from the generic (read arbitrary)
71 // definitions given here.
74 // These values can be overridden in the target configuration file.
75 // The default values are appropriate for many 32-bit targets.
77 // GCC only intrinsically supports modulo integral types. The only remaining
78 // integral exceptional values is division by zero. Only targets that do not
79 // signal division by zero in some "hard to ignore" way should use false.
80 #ifndef __glibcxx_integral_traps
81 # define __glibcxx_integral_traps true
87 // Default values. Should be overridden in configuration files if necessary.
89 #ifndef __glibcxx_float_has_denorm_loss
90 # define __glibcxx_float_has_denorm_loss false
92 #ifndef __glibcxx_float_traps
93 # define __glibcxx_float_traps false
95 #ifndef __glibcxx_float_tinyness_before
96 # define __glibcxx_float_tinyness_before false
101 // Default values. Should be overridden in configuration files if necessary.
103 #ifndef __glibcxx_double_has_denorm_loss
104 # define __glibcxx_double_has_denorm_loss false
106 #ifndef __glibcxx_double_traps
107 # define __glibcxx_double_traps false
109 #ifndef __glibcxx_double_tinyness_before
110 # define __glibcxx_double_tinyness_before false
115 // Default values. Should be overridden in configuration files if necessary.
117 #ifndef __glibcxx_long_double_has_denorm_loss
118 # define __glibcxx_long_double_has_denorm_loss false
120 #ifndef __glibcxx_long_double_traps
121 # define __glibcxx_long_double_traps false
123 #ifndef __glibcxx_long_double_tinyness_before
124 # define __glibcxx_long_double_tinyness_before false
127 // You should not need to define any macros below this point.
129 #define __glibcxx_signed(T) ((T)(-1) < 0)
131 #define __glibcxx_min(T) \
132 (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
134 #define __glibcxx_max(T) \
135 (__glibcxx_signed (T) ? \
136 (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
138 #define __glibcxx_digits(T) \
139 (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
141 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
142 #define __glibcxx_digits10(T) \
143 (__glibcxx_digits (T) * 643 / 2136)
145 #define __glibcxx_max_digits10(T) \
146 (2 + (T) * 643 / 2136)
148 _GLIBCXX_BEGIN_NAMESPACE(std)
151 * @brief Describes the rounding style for floating-point types.
153 * This is used in the std::numeric_limits class.
155 enum float_round_style
157 round_indeterminate = -1, ///< Self-explanatory.
158 round_toward_zero = 0, ///< Self-explanatory.
159 round_to_nearest = 1, ///< To the nearest representable value.
160 round_toward_infinity = 2, ///< Self-explanatory.
161 round_toward_neg_infinity = 3 ///< Self-explanatory.
165 * @brief Describes the denormalization for floating-point types.
167 * These values represent the presence or absence of a variable number
168 * of exponent bits. This type is used in the std::numeric_limits class.
170 enum float_denorm_style
172 /// Indeterminate at compile time whether denormalized values are allowed.
173 denorm_indeterminate = -1,
174 /// The type does not allow denormalized values.
176 /// The type allows denormalized values.
181 * @brief Part of std::numeric_limits.
183 * The @c static @c const members are usable as integral constant
186 * @note This is a separate class for purposes of efficiency; you
187 * should only access these members as part of an instantiation
188 * of the std::numeric_limits class.
190 struct __numeric_limits_base
192 /** This will be true for all fundamental types (which have
193 specializations), and false for everything else. */
194 static const bool is_specialized = false;
196 /** The number of @c radix digits that be represented without change: for
197 integer types, the number of non-sign bits in the mantissa; for
198 floating types, the number of @c radix digits in the mantissa. */
199 static const int digits = 0;
200 /** The number of base 10 digits that can be represented without change. */
201 static const int digits10 = 0;
202 #ifdef __GXX_EXPERIMENTAL_CXX0X__
203 /** The number of base 10 digits required to ensure that values which
204 differ are always differentiated. */
205 static const int max_digits10 = 0;
207 /** True if the type is signed. */
208 static const bool is_signed = false;
209 /** True if the type is integer.
210 * Is this supposed to be <em>if the type is integral?</em> */
211 static const bool is_integer = false;
212 /** True if the type uses an exact representation. <em>All integer types are
213 exact, but not all exact types are integer. For example, rational and
214 fixed-exponent representations are exact but not integer.</em>
216 static const bool is_exact = false;
217 /** For integer types, specifies the base of the representation. For
218 floating types, specifies the base of the exponent representation. */
219 static const int radix = 0;
221 /** The minimum negative integer such that @c radix raised to the power of
222 (one less than that integer) is a normalized floating point number. */
223 static const int min_exponent = 0;
224 /** The minimum negative integer such that 10 raised to that power is in
225 the range of normalized floating point numbers. */
226 static const int min_exponent10 = 0;
227 /** The maximum positive integer such that @c radix raised to the power of
228 (one less than that integer) is a representable finite floating point
230 static const int max_exponent = 0;
231 /** The maximum positive integer such that 10 raised to that power is in
232 the range of representable finite floating point numbers. */
233 static const int max_exponent10 = 0;
235 /** True if the type has a representation for positive infinity. */
236 static const bool has_infinity = false;
237 /** True if the type has a representation for a quiet (non-signaling)
238 <em>Not a Number</em>. */
239 static const bool has_quiet_NaN = false;
240 /** True if the type has a representation for a signaling
241 <em>Not a Number</em>. */
242 static const bool has_signaling_NaN = false;
243 /** See std::float_denorm_style for more information. */
244 static const float_denorm_style has_denorm = denorm_absent;
245 /** <em>True if loss of accuracy is detected as a denormalization loss,
246 rather than as an inexact result.</em> [18.2.1.2]/42 */
247 static const bool has_denorm_loss = false;
249 /** True if-and-only-if the type adheres to the IEC 559 standard, also
250 known as IEEE 754. (Only makes sense for floating point types.) */
251 static const bool is_iec559 = false;
252 /** <em>True if the set of values representable by the type is
253 finite. All built-in types are bounded, this member would be
254 false for arbitrary precision types.</em> [18.2.1.2]/54 */
255 static const bool is_bounded = false;
256 /** True if the type is @e modulo, that is, if it is possible to add two
257 positive numbers and have a result that wraps around to a third number
258 that is less. Typically false for floating types, true for unsigned
259 integers, and true for signed integers. */
260 static const bool is_modulo = false;
262 /** True if trapping is implemented for this type. */
263 static const bool traps = false;
264 /** True if tininess is detected before rounding. (see IEC 559) */
265 static const bool tinyness_before = false;
266 /** See std::float_round_style for more information. This is only
267 meaningful for floating types; integer types will all be
268 round_toward_zero. */
269 static const float_round_style round_style = round_toward_zero;
273 * @brief Properties of fundamental types.
275 * This class allows a program to obtain information about the
276 * representation of a fundamental type on a given platform. For
277 * non-fundamental types, the functions will return 0 and the data
278 * members will all be @c false.
280 * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
281 * noted, but not incorporated in this documented (yet).
283 template<typename _Tp>
284 struct numeric_limits : public __numeric_limits_base
286 /** The minimum finite value, or for floating types with
287 denormalization, the minimum positive normalized value. */
288 static _Tp min() throw() { return static_cast<_Tp>(0); }
289 /** The maximum finite value. */
290 static _Tp max() throw() { return static_cast<_Tp>(0); }
291 #ifdef __GXX_EXPERIMENTAL_CXX0X__
292 /** A finite value x such that there is no other finite value y
294 static _Tp lowest() throw() { return static_cast<_Tp>(0); }
296 /** The @e machine @e epsilon: the difference between 1 and the least
297 value greater than 1 that is representable. */
298 static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
299 /** The maximum rounding error measurement (see LIA-1). */
300 static _Tp round_error() throw() { return static_cast<_Tp>(0); }
301 /** The representation of positive infinity, if @c has_infinity. */
302 static _Tp infinity() throw() { return static_cast<_Tp>(0); }
304 /** The representation of a quiet <em>Not a Number</em>,
305 if @c has_quiet_NaN. */
306 static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
307 /** The representation of a signaling <em>Not a Number</em>, if
308 @c has_signaling_NaN. */
309 static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
310 /** The minimum positive denormalized value. For types where
311 @c has_denorm is false, this is the minimum positive normalized
313 static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
316 #ifdef __GXX_EXPERIMENTAL_CXX0X__
317 template<typename _Tp>
318 struct numeric_limits<const _Tp>
319 : public numeric_limits<_Tp> { };
321 template<typename _Tp>
322 struct numeric_limits<volatile _Tp>
323 : public numeric_limits<_Tp> { };
325 template<typename _Tp>
326 struct numeric_limits<const volatile _Tp>
327 : public numeric_limits<_Tp> { };
330 // Now there follow 16 explicit specializations. Yes, 16. Make sure
331 // you get the count right. (18 in c++0x mode)
333 /// numeric_limits<bool> specialization.
335 struct numeric_limits<bool>
337 static const bool is_specialized = true;
339 static bool min() throw()
341 static bool max() throw()
343 #ifdef __GXX_EXPERIMENTAL_CXX0X__
344 static bool lowest() throw()
347 static const int digits = 1;
348 static const int digits10 = 0;
349 #ifdef __GXX_EXPERIMENTAL_CXX0X__
350 static const int max_digits10 = 0;
352 static const bool is_signed = false;
353 static const bool is_integer = true;
354 static const bool is_exact = true;
355 static const int radix = 2;
356 static bool epsilon() throw()
358 static bool round_error() throw()
361 static const int min_exponent = 0;
362 static const int min_exponent10 = 0;
363 static const int max_exponent = 0;
364 static const int max_exponent10 = 0;
366 static const bool has_infinity = false;
367 static const bool has_quiet_NaN = false;
368 static const bool has_signaling_NaN = false;
369 static const float_denorm_style has_denorm = denorm_absent;
370 static const bool has_denorm_loss = false;
372 static bool infinity() throw()
374 static bool quiet_NaN() throw()
376 static bool signaling_NaN() throw()
378 static bool denorm_min() throw()
381 static const bool is_iec559 = false;
382 static const bool is_bounded = true;
383 static const bool is_modulo = false;
385 // It is not clear what it means for a boolean type to trap.
386 // This is a DR on the LWG issue list. Here, I use integer
387 // promotion semantics.
388 static const bool traps = __glibcxx_integral_traps;
389 static const bool tinyness_before = false;
390 static const float_round_style round_style = round_toward_zero;
393 /// numeric_limits<char> specialization.
395 struct numeric_limits<char>
397 static const bool is_specialized = true;
399 static char min() throw()
400 { return __glibcxx_min(char); }
401 static char max() throw()
402 { return __glibcxx_max(char); }
403 #ifdef __GXX_EXPERIMENTAL_CXX0X__
404 static char lowest() throw()
408 static const int digits = __glibcxx_digits (char);
409 static const int digits10 = __glibcxx_digits10 (char);
410 #ifdef __GXX_EXPERIMENTAL_CXX0X__
411 static const int max_digits10 = 0;
413 static const bool is_signed = __glibcxx_signed (char);
414 static const bool is_integer = true;
415 static const bool is_exact = true;
416 static const int radix = 2;
417 static char epsilon() throw()
419 static char round_error() throw()
422 static const int min_exponent = 0;
423 static const int min_exponent10 = 0;
424 static const int max_exponent = 0;
425 static const int max_exponent10 = 0;
427 static const bool has_infinity = false;
428 static const bool has_quiet_NaN = false;
429 static const bool has_signaling_NaN = false;
430 static const float_denorm_style has_denorm = denorm_absent;
431 static const bool has_denorm_loss = false;
433 static char infinity() throw()
435 static char quiet_NaN() throw()
437 static char signaling_NaN() throw()
439 static char denorm_min() throw()
440 { return static_cast<char>(0); }
442 static const bool is_iec559 = false;
443 static const bool is_bounded = true;
444 static const bool is_modulo = true;
446 static const bool traps = __glibcxx_integral_traps;
447 static const bool tinyness_before = false;
448 static const float_round_style round_style = round_toward_zero;
451 /// numeric_limits<signed char> specialization.
453 struct numeric_limits<signed char>
455 static const bool is_specialized = true;
457 static signed char min() throw()
458 { return -__SCHAR_MAX__ - 1; }
459 static signed char max() throw()
460 { return __SCHAR_MAX__; }
461 #ifdef __GXX_EXPERIMENTAL_CXX0X__
462 static signed char lowest() throw()
466 static const int digits = __glibcxx_digits (signed char);
467 static const int digits10 = __glibcxx_digits10 (signed char);
468 #ifdef __GXX_EXPERIMENTAL_CXX0X__
469 static const int max_digits10 = 0;
471 static const bool is_signed = true;
472 static const bool is_integer = true;
473 static const bool is_exact = true;
474 static const int radix = 2;
475 static signed char epsilon() throw()
477 static signed char round_error() throw()
480 static const int min_exponent = 0;
481 static const int min_exponent10 = 0;
482 static const int max_exponent = 0;
483 static const int max_exponent10 = 0;
485 static const bool has_infinity = false;
486 static const bool has_quiet_NaN = false;
487 static const bool has_signaling_NaN = false;
488 static const float_denorm_style has_denorm = denorm_absent;
489 static const bool has_denorm_loss = false;
491 static signed char infinity() throw()
492 { return static_cast<signed char>(0); }
493 static signed char quiet_NaN() throw()
494 { return static_cast<signed char>(0); }
495 static signed char signaling_NaN() throw()
496 { return static_cast<signed char>(0); }
497 static signed char denorm_min() throw()
498 { return static_cast<signed char>(0); }
500 static const bool is_iec559 = false;
501 static const bool is_bounded = true;
502 static const bool is_modulo = true;
504 static const bool traps = __glibcxx_integral_traps;
505 static const bool tinyness_before = false;
506 static const float_round_style round_style = round_toward_zero;
509 /// numeric_limits<unsigned char> specialization.
511 struct numeric_limits<unsigned char>
513 static const bool is_specialized = true;
515 static unsigned char min() throw()
517 static unsigned char max() throw()
518 { return __SCHAR_MAX__ * 2U + 1; }
519 #ifdef __GXX_EXPERIMENTAL_CXX0X__
520 static unsigned char lowest() throw()
524 static const int digits = __glibcxx_digits (unsigned char);
525 static const int digits10 = __glibcxx_digits10 (unsigned char);
526 #ifdef __GXX_EXPERIMENTAL_CXX0X__
527 static const int max_digits10 = 0;
529 static const bool is_signed = false;
530 static const bool is_integer = true;
531 static const bool is_exact = true;
532 static const int radix = 2;
533 static unsigned char epsilon() throw()
535 static unsigned char round_error() throw()
538 static const int min_exponent = 0;
539 static const int min_exponent10 = 0;
540 static const int max_exponent = 0;
541 static const int max_exponent10 = 0;
543 static const bool has_infinity = false;
544 static const bool has_quiet_NaN = false;
545 static const bool has_signaling_NaN = false;
546 static const float_denorm_style has_denorm = denorm_absent;
547 static const bool has_denorm_loss = false;
549 static unsigned char infinity() throw()
550 { return static_cast<unsigned char>(0); }
551 static unsigned char quiet_NaN() throw()
552 { return static_cast<unsigned char>(0); }
553 static unsigned char signaling_NaN() throw()
554 { return static_cast<unsigned char>(0); }
555 static unsigned char denorm_min() throw()
556 { return static_cast<unsigned char>(0); }
558 static const bool is_iec559 = false;
559 static const bool is_bounded = true;
560 static const bool is_modulo = true;
562 static const bool traps = __glibcxx_integral_traps;
563 static const bool tinyness_before = false;
564 static const float_round_style round_style = round_toward_zero;
567 /// numeric_limits<wchar_t> specialization.
569 struct numeric_limits<wchar_t>
571 static const bool is_specialized = true;
573 static wchar_t min() throw()
574 { return __glibcxx_min (wchar_t); }
575 static wchar_t max() throw()
576 { return __glibcxx_max (wchar_t); }
577 #ifdef __GXX_EXPERIMENTAL_CXX0X__
578 static wchar_t lowest() throw()
582 static const int digits = __glibcxx_digits (wchar_t);
583 static const int digits10 = __glibcxx_digits10 (wchar_t);
584 #ifdef __GXX_EXPERIMENTAL_CXX0X__
585 static const int max_digits10 = 0;
587 static const bool is_signed = __glibcxx_signed (wchar_t);
588 static const bool is_integer = true;
589 static const bool is_exact = true;
590 static const int radix = 2;
591 static wchar_t epsilon() throw()
593 static wchar_t round_error() throw()
596 static const int min_exponent = 0;
597 static const int min_exponent10 = 0;
598 static const int max_exponent = 0;
599 static const int max_exponent10 = 0;
601 static const bool has_infinity = false;
602 static const bool has_quiet_NaN = false;
603 static const bool has_signaling_NaN = false;
604 static const float_denorm_style has_denorm = denorm_absent;
605 static const bool has_denorm_loss = false;
607 static wchar_t infinity() throw()
608 { return wchar_t(); }
609 static wchar_t quiet_NaN() throw()
610 { return wchar_t(); }
611 static wchar_t signaling_NaN() throw()
612 { return wchar_t(); }
613 static wchar_t denorm_min() throw()
614 { return wchar_t(); }
616 static const bool is_iec559 = false;
617 static const bool is_bounded = true;
618 static const bool is_modulo = true;
620 static const bool traps = __glibcxx_integral_traps;
621 static const bool tinyness_before = false;
622 static const float_round_style round_style = round_toward_zero;
625 #ifdef __GXX_EXPERIMENTAL_CXX0X__
626 /// numeric_limits<char16_t> specialization.
628 struct numeric_limits<char16_t>
630 static const bool is_specialized = true;
632 static char16_t min() throw()
633 { return __glibcxx_min (char16_t); }
634 static char16_t max() throw()
635 { return __glibcxx_max (char16_t); }
636 #ifdef __GXX_EXPERIMENTAL_CXX0X__
637 static char16_t lowest() throw()
641 static const int digits = __glibcxx_digits (char16_t);
642 static const int digits10 = __glibcxx_digits10 (char16_t);
643 #ifdef __GXX_EXPERIMENTAL_CXX0X__
644 static const int max_digits10 = 0;
646 static const bool is_signed = __glibcxx_signed (char16_t);
647 static const bool is_integer = true;
648 static const bool is_exact = true;
649 static const int radix = 2;
650 static char16_t epsilon() throw()
652 static char16_t round_error() throw()
655 static const int min_exponent = 0;
656 static const int min_exponent10 = 0;
657 static const int max_exponent = 0;
658 static const int max_exponent10 = 0;
660 static const bool has_infinity = false;
661 static const bool has_quiet_NaN = false;
662 static const bool has_signaling_NaN = false;
663 static const float_denorm_style has_denorm = denorm_absent;
664 static const bool has_denorm_loss = false;
666 static char16_t infinity() throw()
667 { return char16_t(); }
668 static char16_t quiet_NaN() throw()
669 { return char16_t(); }
670 static char16_t signaling_NaN() throw()
671 { return char16_t(); }
672 static char16_t denorm_min() throw()
673 { return char16_t(); }
675 static const bool is_iec559 = false;
676 static const bool is_bounded = true;
677 static const bool is_modulo = true;
679 static const bool traps = __glibcxx_integral_traps;
680 static const bool tinyness_before = false;
681 static const float_round_style round_style = round_toward_zero;
684 /// numeric_limits<char32_t> specialization.
686 struct numeric_limits<char32_t>
688 static const bool is_specialized = true;
690 static char32_t min() throw()
691 { return __glibcxx_min (char32_t); }
692 static char32_t max() throw()
693 { return __glibcxx_max (char32_t); }
694 #ifdef __GXX_EXPERIMENTAL_CXX0X__
695 static char32_t lowest() throw()
699 static const int digits = __glibcxx_digits (char32_t);
700 static const int digits10 = __glibcxx_digits10 (char32_t);
701 #ifdef __GXX_EXPERIMENTAL_CXX0X__
702 static const int max_digits10 = 0;
704 static const bool is_signed = __glibcxx_signed (char32_t);
705 static const bool is_integer = true;
706 static const bool is_exact = true;
707 static const int radix = 2;
708 static char32_t epsilon() throw()
710 static char32_t round_error() throw()
713 static const int min_exponent = 0;
714 static const int min_exponent10 = 0;
715 static const int max_exponent = 0;
716 static const int max_exponent10 = 0;
718 static const bool has_infinity = false;
719 static const bool has_quiet_NaN = false;
720 static const bool has_signaling_NaN = false;
721 static const float_denorm_style has_denorm = denorm_absent;
722 static const bool has_denorm_loss = false;
724 static char32_t infinity() throw()
725 { return char32_t(); }
726 static char32_t quiet_NaN() throw()
727 { return char32_t(); }
728 static char32_t signaling_NaN() throw()
729 { return char32_t(); }
730 static char32_t denorm_min() throw()
731 { return char32_t(); }
733 static const bool is_iec559 = false;
734 static const bool is_bounded = true;
735 static const bool is_modulo = true;
737 static const bool traps = __glibcxx_integral_traps;
738 static const bool tinyness_before = false;
739 static const float_round_style round_style = round_toward_zero;
743 /// numeric_limits<short> specialization.
745 struct numeric_limits<short>
747 static const bool is_specialized = true;
749 static short min() throw()
750 { return -__SHRT_MAX__ - 1; }
751 static short max() throw()
752 { return __SHRT_MAX__; }
753 #ifdef __GXX_EXPERIMENTAL_CXX0X__
754 static short lowest() throw()
758 static const int digits = __glibcxx_digits (short);
759 static const int digits10 = __glibcxx_digits10 (short);
760 #ifdef __GXX_EXPERIMENTAL_CXX0X__
761 static const int max_digits10 = 0;
763 static const bool is_signed = true;
764 static const bool is_integer = true;
765 static const bool is_exact = true;
766 static const int radix = 2;
767 static short epsilon() throw()
769 static short round_error() throw()
772 static const int min_exponent = 0;
773 static const int min_exponent10 = 0;
774 static const int max_exponent = 0;
775 static const int max_exponent10 = 0;
777 static const bool has_infinity = false;
778 static const bool has_quiet_NaN = false;
779 static const bool has_signaling_NaN = false;
780 static const float_denorm_style has_denorm = denorm_absent;
781 static const bool has_denorm_loss = false;
783 static short infinity() throw()
785 static short quiet_NaN() throw()
787 static short signaling_NaN() throw()
789 static short denorm_min() throw()
792 static const bool is_iec559 = false;
793 static const bool is_bounded = true;
794 static const bool is_modulo = true;
796 static const bool traps = __glibcxx_integral_traps;
797 static const bool tinyness_before = false;
798 static const float_round_style round_style = round_toward_zero;
801 /// numeric_limits<unsigned short> specialization.
803 struct numeric_limits<unsigned short>
805 static const bool is_specialized = true;
807 static unsigned short min() throw()
809 static unsigned short max() throw()
810 { return __SHRT_MAX__ * 2U + 1; }
811 #ifdef __GXX_EXPERIMENTAL_CXX0X__
812 static unsigned short lowest() throw()
816 static const int digits = __glibcxx_digits (unsigned short);
817 static const int digits10 = __glibcxx_digits10 (unsigned short);
818 #ifdef __GXX_EXPERIMENTAL_CXX0X__
819 static const int max_digits10 = 0;
821 static const bool is_signed = false;
822 static const bool is_integer = true;
823 static const bool is_exact = true;
824 static const int radix = 2;
825 static unsigned short epsilon() throw()
827 static unsigned short round_error() throw()
830 static const int min_exponent = 0;
831 static const int min_exponent10 = 0;
832 static const int max_exponent = 0;
833 static const int max_exponent10 = 0;
835 static const bool has_infinity = false;
836 static const bool has_quiet_NaN = false;
837 static const bool has_signaling_NaN = false;
838 static const float_denorm_style has_denorm = denorm_absent;
839 static const bool has_denorm_loss = false;
841 static unsigned short infinity() throw()
842 { return static_cast<unsigned short>(0); }
843 static unsigned short quiet_NaN() throw()
844 { return static_cast<unsigned short>(0); }
845 static unsigned short signaling_NaN() throw()
846 { return static_cast<unsigned short>(0); }
847 static unsigned short denorm_min() throw()
848 { return static_cast<unsigned short>(0); }
850 static const bool is_iec559 = false;
851 static const bool is_bounded = true;
852 static const bool is_modulo = true;
854 static const bool traps = __glibcxx_integral_traps;
855 static const bool tinyness_before = false;
856 static const float_round_style round_style = round_toward_zero;
859 /// numeric_limits<int> specialization.
861 struct numeric_limits<int>
863 static const bool is_specialized = true;
865 static int min() throw()
866 { return -__INT_MAX__ - 1; }
867 static int max() throw()
868 { return __INT_MAX__; }
869 #ifdef __GXX_EXPERIMENTAL_CXX0X__
870 static int lowest() throw()
874 static const int digits = __glibcxx_digits (int);
875 static const int digits10 = __glibcxx_digits10 (int);
876 #ifdef __GXX_EXPERIMENTAL_CXX0X__
877 static const int max_digits10 = 0;
879 static const bool is_signed = true;
880 static const bool is_integer = true;
881 static const bool is_exact = true;
882 static const int radix = 2;
883 static int epsilon() throw()
885 static int round_error() throw()
888 static const int min_exponent = 0;
889 static const int min_exponent10 = 0;
890 static const int max_exponent = 0;
891 static const int max_exponent10 = 0;
893 static const bool has_infinity = false;
894 static const bool has_quiet_NaN = false;
895 static const bool has_signaling_NaN = false;
896 static const float_denorm_style has_denorm = denorm_absent;
897 static const bool has_denorm_loss = false;
899 static int infinity() throw()
900 { return static_cast<int>(0); }
901 static int quiet_NaN() throw()
902 { return static_cast<int>(0); }
903 static int signaling_NaN() throw()
904 { return static_cast<int>(0); }
905 static int denorm_min() throw()
906 { return static_cast<int>(0); }
908 static const bool is_iec559 = false;
909 static const bool is_bounded = true;
910 static const bool is_modulo = true;
912 static const bool traps = __glibcxx_integral_traps;
913 static const bool tinyness_before = false;
914 static const float_round_style round_style = round_toward_zero;
917 /// numeric_limits<unsigned int> specialization.
919 struct numeric_limits<unsigned int>
921 static const bool is_specialized = true;
923 static unsigned int min() throw()
925 static unsigned int max() throw()
926 { return __INT_MAX__ * 2U + 1; }
927 #ifdef __GXX_EXPERIMENTAL_CXX0X__
928 static unsigned int lowest() throw()
932 static const int digits = __glibcxx_digits (unsigned int);
933 static const int digits10 = __glibcxx_digits10 (unsigned int);
934 #ifdef __GXX_EXPERIMENTAL_CXX0X__
935 static const int max_digits10 = 0;
937 static const bool is_signed = false;
938 static const bool is_integer = true;
939 static const bool is_exact = true;
940 static const int radix = 2;
941 static unsigned int epsilon() throw()
943 static unsigned int round_error() throw()
946 static const int min_exponent = 0;
947 static const int min_exponent10 = 0;
948 static const int max_exponent = 0;
949 static const int max_exponent10 = 0;
951 static const bool has_infinity = false;
952 static const bool has_quiet_NaN = false;
953 static const bool has_signaling_NaN = false;
954 static const float_denorm_style has_denorm = denorm_absent;
955 static const bool has_denorm_loss = false;
957 static unsigned int infinity() throw()
958 { return static_cast<unsigned int>(0); }
959 static unsigned int quiet_NaN() throw()
960 { return static_cast<unsigned int>(0); }
961 static unsigned int signaling_NaN() throw()
962 { return static_cast<unsigned int>(0); }
963 static unsigned int denorm_min() throw()
964 { return static_cast<unsigned int>(0); }
966 static const bool is_iec559 = false;
967 static const bool is_bounded = true;
968 static const bool is_modulo = true;
970 static const bool traps = __glibcxx_integral_traps;
971 static const bool tinyness_before = false;
972 static const float_round_style round_style = round_toward_zero;
975 /// numeric_limits<long> specialization.
977 struct numeric_limits<long>
979 static const bool is_specialized = true;
981 static long min() throw()
982 { return -__LONG_MAX__ - 1; }
983 static long max() throw()
984 { return __LONG_MAX__; }
985 #ifdef __GXX_EXPERIMENTAL_CXX0X__
986 static long lowest() throw()
990 static const int digits = __glibcxx_digits (long);
991 static const int digits10 = __glibcxx_digits10 (long);
992 #ifdef __GXX_EXPERIMENTAL_CXX0X__
993 static const int max_digits10 = 0;
995 static const bool is_signed = true;
996 static const bool is_integer = true;
997 static const bool is_exact = true;
998 static const int radix = 2;
999 static long epsilon() throw()
1001 static long round_error() throw()
1004 static const int min_exponent = 0;
1005 static const int min_exponent10 = 0;
1006 static const int max_exponent = 0;
1007 static const int max_exponent10 = 0;
1009 static const bool has_infinity = false;
1010 static const bool has_quiet_NaN = false;
1011 static const bool has_signaling_NaN = false;
1012 static const float_denorm_style has_denorm = denorm_absent;
1013 static const bool has_denorm_loss = false;
1015 static long infinity() throw()
1016 { return static_cast<long>(0); }
1017 static long quiet_NaN() throw()
1018 { return static_cast<long>(0); }
1019 static long signaling_NaN() throw()
1020 { return static_cast<long>(0); }
1021 static long denorm_min() throw()
1022 { return static_cast<long>(0); }
1024 static const bool is_iec559 = false;
1025 static const bool is_bounded = true;
1026 static const bool is_modulo = true;
1028 static const bool traps = __glibcxx_integral_traps;
1029 static const bool tinyness_before = false;
1030 static const float_round_style round_style = round_toward_zero;
1033 /// numeric_limits<unsigned long> specialization.
1035 struct numeric_limits<unsigned long>
1037 static const bool is_specialized = true;
1039 static unsigned long min() throw()
1041 static unsigned long max() throw()
1042 { return __LONG_MAX__ * 2UL + 1; }
1043 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1044 static unsigned long lowest() throw()
1048 static const int digits = __glibcxx_digits (unsigned long);
1049 static const int digits10 = __glibcxx_digits10 (unsigned long);
1050 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1051 static const int max_digits10 = 0;
1053 static const bool is_signed = false;
1054 static const bool is_integer = true;
1055 static const bool is_exact = true;
1056 static const int radix = 2;
1057 static unsigned long epsilon() throw()
1059 static unsigned long round_error() throw()
1062 static const int min_exponent = 0;
1063 static const int min_exponent10 = 0;
1064 static const int max_exponent = 0;
1065 static const int max_exponent10 = 0;
1067 static const bool has_infinity = false;
1068 static const bool has_quiet_NaN = false;
1069 static const bool has_signaling_NaN = false;
1070 static const float_denorm_style has_denorm = denorm_absent;
1071 static const bool has_denorm_loss = false;
1073 static unsigned long infinity() throw()
1074 { return static_cast<unsigned long>(0); }
1075 static unsigned long quiet_NaN() throw()
1076 { return static_cast<unsigned long>(0); }
1077 static unsigned long signaling_NaN() throw()
1078 { return static_cast<unsigned long>(0); }
1079 static unsigned long denorm_min() throw()
1080 { return static_cast<unsigned long>(0); }
1082 static const bool is_iec559 = false;
1083 static const bool is_bounded = true;
1084 static const bool is_modulo = true;
1086 static const bool traps = __glibcxx_integral_traps;
1087 static const bool tinyness_before = false;
1088 static const float_round_style round_style = round_toward_zero;
1091 /// numeric_limits<long long> specialization.
1093 struct numeric_limits<long long>
1095 static const bool is_specialized = true;
1097 static long long min() throw()
1098 { return -__LONG_LONG_MAX__ - 1; }
1099 static long long max() throw()
1100 { return __LONG_LONG_MAX__; }
1101 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1102 static long long lowest() throw()
1106 static const int digits = __glibcxx_digits (long long);
1107 static const int digits10 = __glibcxx_digits10 (long long);
1108 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1109 static const int max_digits10 = 0;
1111 static const bool is_signed = true;
1112 static const bool is_integer = true;
1113 static const bool is_exact = true;
1114 static const int radix = 2;
1115 static long long epsilon() throw()
1117 static long long round_error() throw()
1120 static const int min_exponent = 0;
1121 static const int min_exponent10 = 0;
1122 static const int max_exponent = 0;
1123 static const int max_exponent10 = 0;
1125 static const bool has_infinity = false;
1126 static const bool has_quiet_NaN = false;
1127 static const bool has_signaling_NaN = false;
1128 static const float_denorm_style has_denorm = denorm_absent;
1129 static const bool has_denorm_loss = false;
1131 static long long infinity() throw()
1132 { return static_cast<long long>(0); }
1133 static long long quiet_NaN() throw()
1134 { return static_cast<long long>(0); }
1135 static long long signaling_NaN() throw()
1136 { return static_cast<long long>(0); }
1137 static long long denorm_min() throw()
1138 { return static_cast<long long>(0); }
1140 static const bool is_iec559 = false;
1141 static const bool is_bounded = true;
1142 static const bool is_modulo = true;
1144 static const bool traps = __glibcxx_integral_traps;
1145 static const bool tinyness_before = false;
1146 static const float_round_style round_style = round_toward_zero;
1149 /// numeric_limits<unsigned long long> specialization.
1151 struct numeric_limits<unsigned long long>
1153 static const bool is_specialized = true;
1155 static unsigned long long min() throw()
1157 static unsigned long long max() throw()
1158 { return __LONG_LONG_MAX__ * 2ULL + 1; }
1159 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1160 static unsigned long long lowest() throw()
1164 static const int digits = __glibcxx_digits (unsigned long long);
1165 static const int digits10 = __glibcxx_digits10 (unsigned long long);
1166 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1167 static const int max_digits10 = 0;
1169 static const bool is_signed = false;
1170 static const bool is_integer = true;
1171 static const bool is_exact = true;
1172 static const int radix = 2;
1173 static unsigned long long epsilon() throw()
1175 static unsigned long long round_error() throw()
1178 static const int min_exponent = 0;
1179 static const int min_exponent10 = 0;
1180 static const int max_exponent = 0;
1181 static const int max_exponent10 = 0;
1183 static const bool has_infinity = false;
1184 static const bool has_quiet_NaN = false;
1185 static const bool has_signaling_NaN = false;
1186 static const float_denorm_style has_denorm = denorm_absent;
1187 static const bool has_denorm_loss = false;
1189 static unsigned long long infinity() throw()
1190 { return static_cast<unsigned long long>(0); }
1191 static unsigned long long quiet_NaN() throw()
1192 { return static_cast<unsigned long long>(0); }
1193 static unsigned long long signaling_NaN() throw()
1194 { return static_cast<unsigned long long>(0); }
1195 static unsigned long long denorm_min() throw()
1196 { return static_cast<unsigned long long>(0); }
1198 static const bool is_iec559 = false;
1199 static const bool is_bounded = true;
1200 static const bool is_modulo = true;
1202 static const bool traps = __glibcxx_integral_traps;
1203 static const bool tinyness_before = false;
1204 static const float_round_style round_style = round_toward_zero;
1207 /// numeric_limits<float> specialization.
1209 struct numeric_limits<float>
1211 static const bool is_specialized = true;
1213 static float min() throw()
1214 { return __FLT_MIN__; }
1215 static float max() throw()
1216 { return __FLT_MAX__; }
1217 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1218 static float lowest() throw()
1219 { return -__FLT_MAX__; }
1222 static const int digits = __FLT_MANT_DIG__;
1223 static const int digits10 = __FLT_DIG__;
1224 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1225 static const int max_digits10
1226 = __glibcxx_max_digits10 (__FLT_MANT_DIG__);
1228 static const bool is_signed = true;
1229 static const bool is_integer = false;
1230 static const bool is_exact = false;
1231 static const int radix = __FLT_RADIX__;
1232 static float epsilon() throw()
1233 { return __FLT_EPSILON__; }
1234 static float round_error() throw()
1237 static const int min_exponent = __FLT_MIN_EXP__;
1238 static const int min_exponent10 = __FLT_MIN_10_EXP__;
1239 static const int max_exponent = __FLT_MAX_EXP__;
1240 static const int max_exponent10 = __FLT_MAX_10_EXP__;
1242 static const bool has_infinity = __FLT_HAS_INFINITY__;
1243 static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
1244 static const bool has_signaling_NaN = has_quiet_NaN;
1245 static const float_denorm_style has_denorm
1246 = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
1247 static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
1249 static float infinity() throw()
1250 { return __builtin_huge_valf (); }
1251 static float quiet_NaN() throw()
1252 { return __builtin_nanf (""); }
1253 static float signaling_NaN() throw()
1254 { return __builtin_nansf (""); }
1255 static float denorm_min() throw()
1256 { return __FLT_DENORM_MIN__; }
1258 static const bool is_iec559
1259 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1260 static const bool is_bounded = true;
1261 static const bool is_modulo = false;
1263 static const bool traps = __glibcxx_float_traps;
1264 static const bool tinyness_before = __glibcxx_float_tinyness_before;
1265 static const float_round_style round_style = round_to_nearest;
1268 #undef __glibcxx_float_has_denorm_loss
1269 #undef __glibcxx_float_traps
1270 #undef __glibcxx_float_tinyness_before
1272 /// numeric_limits<double> specialization.
1274 struct numeric_limits<double>
1276 static const bool is_specialized = true;
1278 static double min() throw()
1279 { return __DBL_MIN__; }
1280 static double max() throw()
1281 { return __DBL_MAX__; }
1282 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1283 static double lowest() throw()
1284 { return -__DBL_MAX__; }
1287 static const int digits = __DBL_MANT_DIG__;
1288 static const int digits10 = __DBL_DIG__;
1289 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1290 static const int max_digits10
1291 = __glibcxx_max_digits10 (__DBL_MANT_DIG__);
1293 static const bool is_signed = true;
1294 static const bool is_integer = false;
1295 static const bool is_exact = false;
1296 static const int radix = __FLT_RADIX__;
1297 static double epsilon() throw()
1298 { return __DBL_EPSILON__; }
1299 static double round_error() throw()
1302 static const int min_exponent = __DBL_MIN_EXP__;
1303 static const int min_exponent10 = __DBL_MIN_10_EXP__;
1304 static const int max_exponent = __DBL_MAX_EXP__;
1305 static const int max_exponent10 = __DBL_MAX_10_EXP__;
1307 static const bool has_infinity = __DBL_HAS_INFINITY__;
1308 static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
1309 static const bool has_signaling_NaN = has_quiet_NaN;
1310 static const float_denorm_style has_denorm
1311 = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1312 static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
1314 static double infinity() throw()
1315 { return __builtin_huge_val(); }
1316 static double quiet_NaN() throw()
1317 { return __builtin_nan (""); }
1318 static double signaling_NaN() throw()
1319 { return __builtin_nans (""); }
1320 static double denorm_min() throw()
1321 { return __DBL_DENORM_MIN__; }
1323 static const bool is_iec559
1324 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1325 static const bool is_bounded = true;
1326 static const bool is_modulo = false;
1328 static const bool traps = __glibcxx_double_traps;
1329 static const bool tinyness_before = __glibcxx_double_tinyness_before;
1330 static const float_round_style round_style = round_to_nearest;
1333 #undef __glibcxx_double_has_denorm_loss
1334 #undef __glibcxx_double_traps
1335 #undef __glibcxx_double_tinyness_before
1337 /// numeric_limits<long double> specialization.
1339 struct numeric_limits<long double>
1341 static const bool is_specialized = true;
1343 static long double min() throw()
1344 { return __LDBL_MIN__; }
1345 static long double max() throw()
1346 { return __LDBL_MAX__; }
1347 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1348 static long double lowest() throw()
1349 { return -__LDBL_MAX__; }
1352 static const int digits = __LDBL_MANT_DIG__;
1353 static const int digits10 = __LDBL_DIG__;
1354 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1355 static const int max_digits10
1356 = __glibcxx_max_digits10 (__LDBL_MANT_DIG__);
1358 static const bool is_signed = true;
1359 static const bool is_integer = false;
1360 static const bool is_exact = false;
1361 static const int radix = __FLT_RADIX__;
1362 static long double epsilon() throw()
1363 { return __LDBL_EPSILON__; }
1364 static long double round_error() throw()
1367 static const int min_exponent = __LDBL_MIN_EXP__;
1368 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
1369 static const int max_exponent = __LDBL_MAX_EXP__;
1370 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
1372 static const bool has_infinity = __LDBL_HAS_INFINITY__;
1373 static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
1374 static const bool has_signaling_NaN = has_quiet_NaN;
1375 static const float_denorm_style has_denorm
1376 = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1377 static const bool has_denorm_loss
1378 = __glibcxx_long_double_has_denorm_loss;
1380 static long double infinity() throw()
1381 { return __builtin_huge_vall (); }
1382 static long double quiet_NaN() throw()
1383 { return __builtin_nanl (""); }
1384 static long double signaling_NaN() throw()
1385 { return __builtin_nansl (""); }
1386 static long double denorm_min() throw()
1387 { return __LDBL_DENORM_MIN__; }
1389 static const bool is_iec559
1390 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1391 static const bool is_bounded = true;
1392 static const bool is_modulo = false;
1394 static const bool traps = __glibcxx_long_double_traps;
1395 static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
1396 static const float_round_style round_style = round_to_nearest;
1399 #undef __glibcxx_long_double_has_denorm_loss
1400 #undef __glibcxx_long_double_traps
1401 #undef __glibcxx_long_double_tinyness_before
1403 _GLIBCXX_END_NAMESPACE
1405 #undef __glibcxx_signed
1406 #undef __glibcxx_min
1407 #undef __glibcxx_max
1408 #undef __glibcxx_digits
1409 #undef __glibcxx_digits10
1410 #undef __glibcxx_max_digits10
1412 #endif // _GLIBCXX_NUMERIC_LIMITS