1 // The template and inlines for the numeric_limits classes. -*- C++ -*-
3 // Copyright (C) 1999-2013 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file include/limits
26 * This is a Standard C++ Library header.
29 // Note: this is not a conforming implementation.
30 // Written by Gabriel Dos Reis <gdr@codesourcery.com>
37 #ifndef _GLIBCXX_NUMERIC_LIMITS
38 #define _GLIBCXX_NUMERIC_LIMITS 1
40 #pragma GCC system_header
48 // The numeric_limits<> traits document implementation-defined aspects
49 // of fundamental arithmetic data types (integers and floating points).
50 // From Standard C++ point of view, there are 14 such types:
53 // char, signed char, unsigned char, wchar_t (4)
54 // short, unsigned short (2)
56 // long, unsigned long (2)
63 // GNU C++ understands (where supported by the host C-library)
65 // long long, unsigned long long (2)
67 // which brings us to 16 fundamental arithmetic data types in GNU C++.
70 // Since a numeric_limits<> is a bit tricky to get right, we rely on
71 // an interface composed of macros which should be defined in config/os
72 // or config/cpu when they differ from the generic (read arbitrary)
73 // definitions given here.
76 // These values can be overridden in the target configuration file.
77 // The default values are appropriate for many 32-bit targets.
79 // GCC only intrinsically supports modulo integral types. The only remaining
80 // integral exceptional values is division by zero. Only targets that do not
81 // signal division by zero in some "hard to ignore" way should use false.
82 #ifndef __glibcxx_integral_traps
83 # define __glibcxx_integral_traps true
89 // Default values. Should be overridden in configuration files if necessary.
91 #ifndef __glibcxx_float_has_denorm_loss
92 # define __glibcxx_float_has_denorm_loss false
94 #ifndef __glibcxx_float_traps
95 # define __glibcxx_float_traps false
97 #ifndef __glibcxx_float_tinyness_before
98 # define __glibcxx_float_tinyness_before false
103 // Default values. Should be overridden in configuration files if necessary.
105 #ifndef __glibcxx_double_has_denorm_loss
106 # define __glibcxx_double_has_denorm_loss false
108 #ifndef __glibcxx_double_traps
109 # define __glibcxx_double_traps false
111 #ifndef __glibcxx_double_tinyness_before
112 # define __glibcxx_double_tinyness_before false
117 // Default values. Should be overridden in configuration files if necessary.
119 #ifndef __glibcxx_long_double_has_denorm_loss
120 # define __glibcxx_long_double_has_denorm_loss false
122 #ifndef __glibcxx_long_double_traps
123 # define __glibcxx_long_double_traps false
125 #ifndef __glibcxx_long_double_tinyness_before
126 # define __glibcxx_long_double_tinyness_before false
129 // You should not need to define any macros below this point.
131 #define __glibcxx_signed(T) ((T)(-1) < 0)
133 #define __glibcxx_min(T) \
134 (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0)
136 #define __glibcxx_max(T) \
137 (__glibcxx_signed (T) ? \
138 (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
140 #define __glibcxx_digits(T) \
141 (sizeof(T) * CHAR_BIT - __glibcxx_signed (T))
143 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
144 #define __glibcxx_digits10(T) \
145 (__glibcxx_digits (T) * 643L / 2136)
147 #define __glibcxx_max_digits10(T) \
148 (2 + (T) * 643L / 2136)
154 * @brief Describes the rounding style for floating-point types.
156 * This is used in the std::numeric_limits class.
158 enum float_round_style
160 round_indeterminate = -1, /// Intermediate.
161 round_toward_zero = 0, /// To zero.
162 round_to_nearest = 1, /// To the nearest representable value.
163 round_toward_infinity = 2, /// To infinity.
164 round_toward_neg_infinity = 3 /// To negative infinity.
168 * @brief Describes the denormalization for floating-point types.
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.
173 enum float_denorm_style
175 /// Indeterminate at compile time whether denormalized values are allowed.
176 denorm_indeterminate = -1,
177 /// The type does not allow denormalized values.
179 /// The type allows denormalized values.
184 * @brief Part of std::numeric_limits.
186 * The @c static @c const members are usable as integral constant
189 * @note This is a separate class for purposes of efficiency; you
190 * should only access these members as part of an instantiation
191 * of the std::numeric_limits class.
193 struct __numeric_limits_base
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;
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;
204 /** The number of base 10 digits that can be represented without change. */
205 static const int digits10 = 0;
207 #if __cplusplus >= 201103L
208 /** The number of base 10 digits required to ensure that values which
209 differ are always differentiated. */
210 static constexpr int max_digits10 = 0;
213 /** True if the type is signed. */
214 static const bool is_signed = false;
216 /** True if the type is integer. */
217 static const bool is_integer = false;
219 /** True if the type uses an exact representation. All integer types are
220 exact, but not all exact types are integer. For example, rational and
221 fixed-exponent representations are exact but not integer. */
222 static const bool is_exact = false;
224 /** For integer types, specifies the base of the representation. For
225 floating types, specifies the base of the exponent representation. */
226 static const int radix = 0;
228 /** The minimum negative integer such that @c radix raised to the power of
229 (one less than that integer) is a normalized floating point number. */
230 static const int min_exponent = 0;
232 /** The minimum negative integer such that 10 raised to that power is in
233 the range of normalized floating point numbers. */
234 static const int min_exponent10 = 0;
236 /** The maximum positive integer such that @c radix raised to the power of
237 (one less than that integer) is a representable finite floating point
239 static const int max_exponent = 0;
241 /** The maximum positive integer such that 10 raised to that power is in
242 the range of representable finite floating point numbers. */
243 static const int max_exponent10 = 0;
245 /** True if the type has a representation for positive infinity. */
246 static const bool has_infinity = false;
248 /** True if the type has a representation for a quiet (non-signaling)
250 static const bool has_quiet_NaN = false;
252 /** True if the type has a representation for a signaling
254 static const bool has_signaling_NaN = false;
256 /** See std::float_denorm_style for more information. */
257 static const float_denorm_style has_denorm = denorm_absent;
259 /** True if loss of accuracy is detected as a denormalization loss,
260 rather than as an inexact result. */
261 static const bool has_denorm_loss = false;
263 /** True if-and-only-if the type adheres to the IEC 559 standard, also
264 known as IEEE 754. (Only makes sense for floating point types.) */
265 static const bool is_iec559 = false;
267 /** True if the set of values representable by the type is
268 finite. All built-in types are bounded, this member would be
269 false for arbitrary precision types. */
270 static const bool is_bounded = false;
272 /** True if the type is @e modulo. A type is modulo if, for any
273 operation involving +, -, or * on values of that type whose
274 result would fall outside the range [min(),max()], the value
275 returned differs from the true value by an integer multiple of
276 max() - min() + 1. On most machines, this is false for floating
277 types, true for unsigned integers, and true for signed integers.
278 See PR22200 about signed integers. */
279 static const bool is_modulo = false;
281 /** True if trapping is implemented for this type. */
282 static const bool traps = false;
284 /** True if tininess is detected before rounding. (see IEC 559) */
285 static const bool tinyness_before = false;
287 /** See std::float_round_style for more information. This is only
288 meaningful for floating types; integer types will all be
289 round_toward_zero. */
290 static const float_round_style round_style =
295 * @brief Properties of fundamental types.
297 * This class allows a program to obtain information about the
298 * representation of a fundamental type on a given platform. For
299 * non-fundamental types, the functions will return 0 and the data
300 * members will all be @c false.
302 * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
303 * noted, but not incorporated in this documented (yet).
305 template<typename _Tp>
306 struct numeric_limits : public __numeric_limits_base
308 /** The minimum finite value, or for floating types with
309 denormalization, the minimum positive normalized value. */
311 min() { return _Tp(); }
313 /** The maximum finite value. */
315 max() { return _Tp(); }
317 #if __cplusplus >= 201103L
318 /** A finite value x such that there is no other finite value y
321 lowest() noexcept { return _Tp(); }
324 /** The @e machine @e epsilon: the difference between 1 and the least
325 value greater than 1 that is representable. */
327 epsilon() { return _Tp(); }
329 /** The maximum rounding error measurement (see LIA-1). */
331 round_error() { return _Tp(); }
333 /** The representation of positive infinity, if @c has_infinity. */
335 infinity() { return _Tp(); }
337 /** The representation of a quiet Not a Number,
338 if @c has_quiet_NaN. */
340 quiet_NaN() { return _Tp(); }
342 /** The representation of a signaling Not a Number, if
343 @c has_signaling_NaN. */
345 signaling_NaN() { return _Tp(); }
347 /** The minimum positive denormalized value. For types where
348 @c has_denorm is false, this is the minimum positive normalized
351 denorm_min() { return _Tp(); }
354 #if __cplusplus >= 201103L
355 template<typename _Tp>
356 struct numeric_limits<const _Tp>
357 : public numeric_limits<_Tp> { };
359 template<typename _Tp>
360 struct numeric_limits<volatile _Tp>
361 : public numeric_limits<_Tp> { };
363 template<typename _Tp>
364 struct numeric_limits<const volatile _Tp>
365 : public numeric_limits<_Tp> { };
368 // Now there follow 16 explicit specializations. Yes, 16. Make sure
369 // you get the count right. (18 in c++0x mode)
371 /// numeric_limits<bool> specialization.
373 struct numeric_limits<bool>
375 static const bool is_specialized = true;
378 min() { return false; }
381 max() { return true; }
383 #if __cplusplus >= 201103L
384 static constexpr bool
385 lowest() noexcept { return min(); }
387 static const int digits = 1;
388 static const int digits10 = 0;
389 #if __cplusplus >= 201103L
390 static constexpr int max_digits10 = 0;
392 static const bool is_signed = false;
393 static const bool is_integer = true;
394 static const bool is_exact = true;
395 static const int radix = 2;
398 epsilon() { return false; }
401 round_error() { return false; }
403 static const int min_exponent = 0;
404 static const int min_exponent10 = 0;
405 static const int max_exponent = 0;
406 static const int max_exponent10 = 0;
408 static const bool has_infinity = false;
409 static const bool has_quiet_NaN = false;
410 static const bool has_signaling_NaN = false;
411 static const float_denorm_style has_denorm
413 static const bool has_denorm_loss = false;
416 infinity() { return false; }
419 quiet_NaN() { return false; }
422 signaling_NaN() { return false; }
425 denorm_min() { return false; }
427 static const bool is_iec559 = false;
428 static const bool is_bounded = true;
429 static const bool is_modulo = false;
431 // It is not clear what it means for a boolean type to trap.
432 // This is a DR on the LWG issue list. Here, I use integer
433 // promotion semantics.
434 static const bool traps = __glibcxx_integral_traps;
435 static const bool tinyness_before = false;
436 static const float_round_style round_style
440 /// numeric_limits<char> specialization.
442 struct numeric_limits<char>
444 static const bool is_specialized = true;
447 min() { return __glibcxx_min(char); }
450 max() { return __glibcxx_max(char); }
452 #if __cplusplus >= 201103L
453 static constexpr char
454 lowest() noexcept { return min(); }
457 static const int digits = __glibcxx_digits (char);
458 static const int digits10 = __glibcxx_digits10 (char);
459 #if __cplusplus >= 201103L
460 static constexpr int max_digits10 = 0;
462 static const bool is_signed = __glibcxx_signed (char);
463 static const bool is_integer = true;
464 static const bool is_exact = true;
465 static const int radix = 2;
468 epsilon() { return 0; }
471 round_error() { return 0; }
473 static const int min_exponent = 0;
474 static const int min_exponent10 = 0;
475 static const int max_exponent = 0;
476 static const int max_exponent10 = 0;
478 static const bool has_infinity = false;
479 static const bool has_quiet_NaN = false;
480 static const bool has_signaling_NaN = false;
481 static const float_denorm_style has_denorm
483 static const bool has_denorm_loss = false;
486 char infinity() { return char(); }
489 quiet_NaN() { return char(); }
492 signaling_NaN() { return char(); }
495 denorm_min() { return static_cast<char>(0); }
497 static const bool is_iec559 = false;
498 static const bool is_bounded = true;
499 static const bool is_modulo = !is_signed;
501 static const bool traps = __glibcxx_integral_traps;
502 static const bool tinyness_before = false;
503 static const float_round_style round_style
507 /// numeric_limits<signed char> specialization.
509 struct numeric_limits<signed char>
511 static const bool is_specialized = true;
513 static const signed char
514 min() { return -SCHAR_MAX - 1; }
516 static const signed char
517 max() { return SCHAR_MAX; }
519 #if __cplusplus >= 201103L
520 static constexpr signed char
521 lowest() noexcept { return min(); }
524 static const int digits = __glibcxx_digits (signed char);
525 static const int digits10
526 = __glibcxx_digits10 (signed char);
527 #if __cplusplus >= 201103L
528 static constexpr int max_digits10 = 0;
530 static const bool is_signed = true;
531 static const bool is_integer = true;
532 static const bool is_exact = true;
533 static const int radix = 2;
535 static const signed char
536 epsilon() { return 0; }
538 static const signed char
539 round_error() { return 0; }
541 static const int min_exponent = 0;
542 static const int min_exponent10 = 0;
543 static const int max_exponent = 0;
544 static const int max_exponent10 = 0;
546 static const bool has_infinity = false;
547 static const bool has_quiet_NaN = false;
548 static const bool has_signaling_NaN = false;
549 static const float_denorm_style has_denorm
551 static const bool has_denorm_loss = false;
553 static const signed char
554 infinity() { return static_cast<signed char>(0); }
556 static const signed char
557 quiet_NaN() { return static_cast<signed char>(0); }
559 static const signed char
561 { return static_cast<signed char>(0); }
563 static const signed char
565 { return static_cast<signed char>(0); }
567 static const bool is_iec559 = false;
568 static const bool is_bounded = true;
569 static const bool is_modulo = false;
571 static const bool traps = __glibcxx_integral_traps;
572 static const bool tinyness_before = false;
573 static const float_round_style round_style
577 /// numeric_limits<unsigned char> specialization.
579 struct numeric_limits<unsigned char>
581 static const bool is_specialized = true;
583 static const unsigned char
586 static const unsigned char
587 max() { return SCHAR_MAX * 2U + 1; }
589 #if __cplusplus >= 201103L
590 static constexpr unsigned char
591 lowest() noexcept { return min(); }
594 static const int digits
595 = __glibcxx_digits (unsigned char);
596 static const int digits10
597 = __glibcxx_digits10 (unsigned char);
598 #if __cplusplus >= 201103L
599 static constexpr int max_digits10 = 0;
601 static const bool is_signed = false;
602 static const bool is_integer = true;
603 static const bool is_exact = true;
604 static const int radix = 2;
606 static const unsigned char
607 epsilon() { return 0; }
609 static const unsigned char
610 round_error() { return 0; }
612 static const int min_exponent = 0;
613 static const int min_exponent10 = 0;
614 static const int max_exponent = 0;
615 static const int max_exponent10 = 0;
617 static const bool has_infinity = false;
618 static const bool has_quiet_NaN = false;
619 static const bool has_signaling_NaN = false;
620 static const float_denorm_style has_denorm
622 static const bool has_denorm_loss = false;
624 static const unsigned char
626 { return static_cast<unsigned char>(0); }
628 static const unsigned char
630 { return static_cast<unsigned char>(0); }
632 static const unsigned char
634 { return static_cast<unsigned char>(0); }
636 static const unsigned char
638 { return static_cast<unsigned char>(0); }
640 static const bool is_iec559 = false;
641 static const bool is_bounded = true;
642 static const bool is_modulo = true;
644 static const bool traps = __glibcxx_integral_traps;
645 static const bool tinyness_before = false;
646 static const float_round_style round_style
650 /// numeric_limits<wchar_t> specialization.
652 struct numeric_limits<wchar_t>
654 static const bool is_specialized = true;
657 min() { return __glibcxx_min (wchar_t); }
660 max() { return __glibcxx_max (wchar_t); }
662 #if __cplusplus >= 201103L
663 static constexpr wchar_t
664 lowest() noexcept { return min(); }
667 static const int digits = __glibcxx_digits (wchar_t);
668 static const int digits10
669 = __glibcxx_digits10 (wchar_t);
670 #if __cplusplus >= 201103L
671 static constexpr int max_digits10 = 0;
673 static const bool is_signed = __glibcxx_signed (wchar_t);
674 static const bool is_integer = true;
675 static const bool is_exact = true;
676 static const int radix = 2;
679 epsilon() { return 0; }
682 round_error() { return 0; }
684 static const int min_exponent = 0;
685 static const int min_exponent10 = 0;
686 static const int max_exponent = 0;
687 static const int max_exponent10 = 0;
689 static const bool has_infinity = false;
690 static const bool has_quiet_NaN = false;
691 static const bool has_signaling_NaN = false;
692 static const float_denorm_style has_denorm
694 static const bool has_denorm_loss = false;
697 infinity() { return wchar_t(); }
700 quiet_NaN() { return wchar_t(); }
703 signaling_NaN() { return wchar_t(); }
706 denorm_min() { return wchar_t(); }
708 static const bool is_iec559 = false;
709 static const bool is_bounded = true;
710 static const bool is_modulo = !is_signed;
712 static const bool traps = __glibcxx_integral_traps;
713 static const bool tinyness_before = false;
714 static const float_round_style round_style
718 #if __cplusplus >= 201103L
719 /// numeric_limits<char16_t> specialization.
721 struct numeric_limits<char16_t>
723 static constexpr bool is_specialized = true;
725 static constexpr char16_t
726 min() noexcept { return __glibcxx_min (char16_t); }
728 static constexpr char16_t
729 max() noexcept { return __glibcxx_max (char16_t); }
731 static constexpr char16_t
732 lowest() noexcept { return min(); }
734 static constexpr int digits = __glibcxx_digits (char16_t);
735 static constexpr int digits10 = __glibcxx_digits10 (char16_t);
736 static constexpr int max_digits10 = 0;
737 static constexpr bool is_signed = __glibcxx_signed (char16_t);
738 static constexpr bool is_integer = true;
739 static constexpr bool is_exact = true;
740 static constexpr int radix = 2;
742 static constexpr char16_t
743 epsilon() noexcept { return 0; }
745 static constexpr char16_t
746 round_error() noexcept { return 0; }
748 static constexpr int min_exponent = 0;
749 static constexpr int min_exponent10 = 0;
750 static constexpr int max_exponent = 0;
751 static constexpr int max_exponent10 = 0;
753 static constexpr bool has_infinity = false;
754 static constexpr bool has_quiet_NaN = false;
755 static constexpr bool has_signaling_NaN = false;
756 static constexpr float_denorm_style has_denorm = denorm_absent;
757 static constexpr bool has_denorm_loss = false;
759 static constexpr char16_t
760 infinity() noexcept { return char16_t(); }
762 static constexpr char16_t
763 quiet_NaN() noexcept { return char16_t(); }
765 static constexpr char16_t
766 signaling_NaN() noexcept { return char16_t(); }
768 static constexpr char16_t
769 denorm_min() noexcept { return char16_t(); }
771 static constexpr bool is_iec559 = false;
772 static constexpr bool is_bounded = true;
773 static constexpr bool is_modulo = !is_signed;
775 static constexpr bool traps = __glibcxx_integral_traps;
776 static constexpr bool tinyness_before = false;
777 static constexpr float_round_style round_style = round_toward_zero;
780 /// numeric_limits<char32_t> specialization.
782 struct numeric_limits<char32_t>
784 static constexpr bool is_specialized = true;
786 static constexpr char32_t
787 min() noexcept { return __glibcxx_min (char32_t); }
789 static constexpr char32_t
790 max() noexcept { return __glibcxx_max (char32_t); }
792 static constexpr char32_t
793 lowest() noexcept { return min(); }
795 static constexpr int digits = __glibcxx_digits (char32_t);
796 static constexpr int digits10 = __glibcxx_digits10 (char32_t);
797 static constexpr int max_digits10 = 0;
798 static constexpr bool is_signed = __glibcxx_signed (char32_t);
799 static constexpr bool is_integer = true;
800 static constexpr bool is_exact = true;
801 static constexpr int radix = 2;
803 static constexpr char32_t
804 epsilon() noexcept { return 0; }
806 static constexpr char32_t
807 round_error() noexcept { return 0; }
809 static constexpr int min_exponent = 0;
810 static constexpr int min_exponent10 = 0;
811 static constexpr int max_exponent = 0;
812 static constexpr int max_exponent10 = 0;
814 static constexpr bool has_infinity = false;
815 static constexpr bool has_quiet_NaN = false;
816 static constexpr bool has_signaling_NaN = false;
817 static constexpr float_denorm_style has_denorm = denorm_absent;
818 static constexpr bool has_denorm_loss = false;
820 static constexpr char32_t
821 infinity() noexcept { return char32_t(); }
823 static constexpr char32_t
824 quiet_NaN() noexcept { return char32_t(); }
826 static constexpr char32_t
827 signaling_NaN() noexcept { return char32_t(); }
829 static constexpr char32_t
830 denorm_min() noexcept { return char32_t(); }
832 static constexpr bool is_iec559 = false;
833 static constexpr bool is_bounded = true;
834 static constexpr bool is_modulo = !is_signed;
836 static constexpr bool traps = __glibcxx_integral_traps;
837 static constexpr bool tinyness_before = false;
838 static constexpr float_round_style round_style = round_toward_zero;
842 /// numeric_limits<short> specialization.
844 struct numeric_limits<short>
846 static const bool is_specialized = true;
849 min() { return -SHRT_MAX - 1; }
852 max() { return SHRT_MAX; }
854 #if __cplusplus >= 201103L
855 static constexpr short
856 lowest() noexcept { return min(); }
859 static const int digits = __glibcxx_digits (short);
860 static const int digits10 = __glibcxx_digits10 (short);
861 #if __cplusplus >= 201103L
862 static constexpr int max_digits10 = 0;
864 static const bool is_signed = true;
865 static const bool is_integer = true;
866 static const bool is_exact = true;
867 static const int radix = 2;
870 epsilon() { return 0; }
873 round_error() { return 0; }
875 static const int min_exponent = 0;
876 static const int min_exponent10 = 0;
877 static const int max_exponent = 0;
878 static const int max_exponent10 = 0;
880 static const bool has_infinity = false;
881 static const bool has_quiet_NaN = false;
882 static const bool has_signaling_NaN = false;
883 static const float_denorm_style has_denorm
885 static const bool has_denorm_loss = false;
888 infinity() { return short(); }
891 quiet_NaN() { return short(); }
894 signaling_NaN() { return short(); }
897 denorm_min() { return short(); }
899 static const bool is_iec559 = false;
900 static const bool is_bounded = true;
901 static const bool is_modulo = false;
903 static const bool traps = __glibcxx_integral_traps;
904 static const bool tinyness_before = false;
905 static const float_round_style round_style
909 /// numeric_limits<unsigned short> specialization.
911 struct numeric_limits<unsigned short>
913 static const bool is_specialized = true;
915 static const unsigned short
918 static const unsigned short
919 max() { return SHRT_MAX * 2U + 1; }
921 #if __cplusplus >= 201103L
922 static constexpr unsigned short
923 lowest() noexcept { return min(); }
926 static const int digits
927 = __glibcxx_digits (unsigned short);
928 static const int digits10
929 = __glibcxx_digits10 (unsigned short);
930 #if __cplusplus >= 201103L
931 static constexpr int max_digits10 = 0;
933 static const bool is_signed = false;
934 static const bool is_integer = true;
935 static const bool is_exact = true;
936 static const int radix = 2;
938 static const unsigned short
939 epsilon() { return 0; }
941 static const unsigned short
942 round_error() { return 0; }
944 static const int min_exponent = 0;
945 static const int min_exponent10 = 0;
946 static const int max_exponent = 0;
947 static const int max_exponent10 = 0;
949 static const bool has_infinity = false;
950 static const bool has_quiet_NaN = false;
951 static const bool has_signaling_NaN = false;
952 static const float_denorm_style has_denorm
954 static const bool has_denorm_loss = false;
956 static const unsigned short
958 { return static_cast<unsigned short>(0); }
960 static const unsigned short
962 { return static_cast<unsigned short>(0); }
964 static const unsigned short
966 { return static_cast<unsigned short>(0); }
968 static const unsigned short
970 { return static_cast<unsigned short>(0); }
972 static const bool is_iec559 = false;
973 static const bool is_bounded = true;
974 static const bool is_modulo = true;
976 static const bool traps = __glibcxx_integral_traps;
977 static const bool tinyness_before = false;
978 static const float_round_style round_style
982 /// numeric_limits<int> specialization.
984 struct numeric_limits<int>
986 static const bool is_specialized = true;
989 min() { return -__INT_MAX__ - 1; }
992 max() { return __INT_MAX__; }
994 #if __cplusplus >= 201103L
996 lowest() noexcept { return min(); }
999 static const int digits = __glibcxx_digits (int);
1000 static const int digits10 = __glibcxx_digits10 (int);
1001 #if __cplusplus >= 201103L
1002 static constexpr int max_digits10 = 0;
1004 static const bool is_signed = true;
1005 static const bool is_integer = true;
1006 static const bool is_exact = true;
1007 static const int radix = 2;
1010 epsilon() { return 0; }
1013 round_error() { return 0; }
1015 static const int min_exponent = 0;
1016 static const int min_exponent10 = 0;
1017 static const int max_exponent = 0;
1018 static const int max_exponent10 = 0;
1020 static const bool has_infinity = false;
1021 static const bool has_quiet_NaN = false;
1022 static const bool has_signaling_NaN = false;
1023 static const float_denorm_style has_denorm
1025 static const bool has_denorm_loss = false;
1028 infinity() { return static_cast<int>(0); }
1031 quiet_NaN() { return static_cast<int>(0); }
1034 signaling_NaN() { return static_cast<int>(0); }
1037 denorm_min() { return static_cast<int>(0); }
1039 static const bool is_iec559 = false;
1040 static const bool is_bounded = true;
1041 static const bool is_modulo = false;
1043 static const bool traps = __glibcxx_integral_traps;
1044 static const bool tinyness_before = false;
1045 static const float_round_style round_style
1046 = round_toward_zero;
1049 /// numeric_limits<unsigned int> specialization.
1051 struct numeric_limits<unsigned int>
1053 static const bool is_specialized = true;
1055 static const unsigned int
1058 static const unsigned int
1059 max() { return __INT_MAX__ * 2U + 1; }
1061 #if __cplusplus >= 201103L
1062 static constexpr unsigned int
1063 lowest() noexcept { return min(); }
1066 static const int digits
1067 = __glibcxx_digits (unsigned int);
1068 static const int digits10
1069 = __glibcxx_digits10 (unsigned int);
1070 #if __cplusplus >= 201103L
1071 static constexpr int max_digits10 = 0;
1073 static const bool is_signed = false;
1074 static const bool is_integer = true;
1075 static const bool is_exact = true;
1076 static const int radix = 2;
1078 static const unsigned int
1079 epsilon() { return 0; }
1081 static const unsigned int
1082 round_error() { return 0; }
1084 static const int min_exponent = 0;
1085 static const int min_exponent10 = 0;
1086 static const int max_exponent = 0;
1087 static const int max_exponent10 = 0;
1089 static const bool has_infinity = false;
1090 static const bool has_quiet_NaN = false;
1091 static const bool has_signaling_NaN = false;
1092 static const float_denorm_style has_denorm
1094 static const bool has_denorm_loss = false;
1096 static const unsigned int
1097 infinity() { return static_cast<unsigned int>(0); }
1099 static const unsigned int
1101 { return static_cast<unsigned int>(0); }
1103 static const unsigned int
1105 { return static_cast<unsigned int>(0); }
1107 static const unsigned int
1109 { return static_cast<unsigned int>(0); }
1111 static const bool is_iec559 = false;
1112 static const bool is_bounded = true;
1113 static const bool is_modulo = true;
1115 static const bool traps = __glibcxx_integral_traps;
1116 static const bool tinyness_before = false;
1117 static const float_round_style round_style
1118 = round_toward_zero;
1121 /// numeric_limits<long> specialization.
1123 struct numeric_limits<long>
1125 static const bool is_specialized = true;
1128 min() { return -__LONG_MAX__ - 1; }
1131 max() { return __LONG_MAX__; }
1133 #if __cplusplus >= 201103L
1134 static constexpr long
1135 lowest() noexcept { return min(); }
1138 static const int digits = __glibcxx_digits (long);
1139 static const int digits10 = __glibcxx_digits10 (long);
1140 #if __cplusplus >= 201103L
1141 static constexpr int max_digits10 = 0;
1143 static const bool is_signed = true;
1144 static const bool is_integer = true;
1145 static const bool is_exact = true;
1146 static const int radix = 2;
1149 epsilon() { return 0; }
1152 round_error() { return 0; }
1154 static const int min_exponent = 0;
1155 static const int min_exponent10 = 0;
1156 static const int max_exponent = 0;
1157 static const int max_exponent10 = 0;
1159 static const bool has_infinity = false;
1160 static const bool has_quiet_NaN = false;
1161 static const bool has_signaling_NaN = false;
1162 static const float_denorm_style has_denorm
1164 static const bool has_denorm_loss = false;
1167 infinity() { return static_cast<long>(0); }
1170 quiet_NaN() { return static_cast<long>(0); }
1173 signaling_NaN() { return static_cast<long>(0); }
1176 denorm_min() { return static_cast<long>(0); }
1178 static const bool is_iec559 = false;
1179 static const bool is_bounded = true;
1180 static const bool is_modulo = false;
1182 static const bool traps = __glibcxx_integral_traps;
1183 static const bool tinyness_before = false;
1184 static const float_round_style round_style
1185 = round_toward_zero;
1188 /// numeric_limits<unsigned long> specialization.
1190 struct numeric_limits<unsigned long>
1192 static const bool is_specialized = true;
1194 static const unsigned long
1197 static const unsigned long
1198 max() { return __LONG_MAX__ * 2UL + 1; }
1200 #if __cplusplus >= 201103L
1201 static constexpr unsigned long
1202 lowest() noexcept { return min(); }
1205 static const int digits
1206 = __glibcxx_digits (unsigned long);
1207 static const int digits10
1208 = __glibcxx_digits10 (unsigned long);
1209 #if __cplusplus >= 201103L
1210 static constexpr int max_digits10 = 0;
1212 static const bool is_signed = false;
1213 static const bool is_integer = true;
1214 static const bool is_exact = true;
1215 static const int radix = 2;
1217 static const unsigned long
1218 epsilon() { return 0; }
1220 static const unsigned long
1221 round_error() { return 0; }
1223 static const int min_exponent = 0;
1224 static const int min_exponent10 = 0;
1225 static const int max_exponent = 0;
1226 static const int max_exponent10 = 0;
1228 static const bool has_infinity = false;
1229 static const bool has_quiet_NaN = false;
1230 static const bool has_signaling_NaN = false;
1231 static const float_denorm_style has_denorm
1233 static const bool has_denorm_loss = false;
1235 static const unsigned long
1237 { return static_cast<unsigned long>(0); }
1239 static const unsigned long
1241 { return static_cast<unsigned long>(0); }
1243 static const unsigned long
1245 { return static_cast<unsigned long>(0); }
1247 static const unsigned long
1249 { return static_cast<unsigned long>(0); }
1251 static const bool is_iec559 = false;
1252 static const bool is_bounded = true;
1253 static const bool is_modulo = true;
1255 static const bool traps = __glibcxx_integral_traps;
1256 static const bool tinyness_before = false;
1257 static const float_round_style round_style
1258 = round_toward_zero;
1261 /// numeric_limits<long long> specialization.
1263 struct numeric_limits<long long>
1265 static const bool is_specialized = true;
1267 static const long long
1268 min() { return -__LONG_LONG_MAX__ - 1; }
1270 static const long long
1271 max() { return __LONG_LONG_MAX__; }
1273 #if __cplusplus >= 201103L
1274 static constexpr long long
1275 lowest() noexcept { return min(); }
1278 static const int digits
1279 = __glibcxx_digits (long long);
1280 static const int digits10
1281 = __glibcxx_digits10 (long long);
1282 #if __cplusplus >= 201103L
1283 static constexpr int max_digits10 = 0;
1285 static const bool is_signed = true;
1286 static const bool is_integer = true;
1287 static const bool is_exact = true;
1288 static const int radix = 2;
1290 static const long long
1291 epsilon() { return 0; }
1293 static const long long
1294 round_error() { return 0; }
1296 static const int min_exponent = 0;
1297 static const int min_exponent10 = 0;
1298 static const int max_exponent = 0;
1299 static const int max_exponent10 = 0;
1301 static const bool has_infinity = false;
1302 static const bool has_quiet_NaN = false;
1303 static const bool has_signaling_NaN = false;
1304 static const float_denorm_style has_denorm
1306 static const bool has_denorm_loss = false;
1308 static const long long
1309 infinity() { return static_cast<long long>(0); }
1311 static const long long
1312 quiet_NaN() { return static_cast<long long>(0); }
1314 static const long long
1316 { return static_cast<long long>(0); }
1318 static const long long
1319 denorm_min() { return static_cast<long long>(0); }
1321 static const bool is_iec559 = false;
1322 static const bool is_bounded = true;
1323 static const bool is_modulo = false;
1325 static const bool traps = __glibcxx_integral_traps;
1326 static const bool tinyness_before = false;
1327 static const float_round_style round_style
1328 = round_toward_zero;
1331 /// numeric_limits<unsigned long long> specialization.
1333 struct numeric_limits<unsigned long long>
1335 static const bool is_specialized = true;
1337 static const unsigned long long
1340 static const unsigned long long
1341 max() { return __LONG_LONG_MAX__ * 2ULL + 1; }
1343 #if __cplusplus >= 201103L
1344 static constexpr unsigned long long
1345 lowest() noexcept { return min(); }
1348 static const int digits
1349 = __glibcxx_digits (unsigned long long);
1350 static const int digits10
1351 = __glibcxx_digits10 (unsigned long long);
1352 #if __cplusplus >= 201103L
1353 static constexpr int max_digits10 = 0;
1355 static const bool is_signed = false;
1356 static const bool is_integer = true;
1357 static const bool is_exact = true;
1358 static const int radix = 2;
1360 static const unsigned long long
1361 epsilon() { return 0; }
1363 static const unsigned long long
1364 round_error() { return 0; }
1366 static const int min_exponent = 0;
1367 static const int min_exponent10 = 0;
1368 static const int max_exponent = 0;
1369 static const int max_exponent10 = 0;
1371 static const bool has_infinity = false;
1372 static const bool has_quiet_NaN = false;
1373 static const bool has_signaling_NaN = false;
1374 static const float_denorm_style has_denorm
1376 static const bool has_denorm_loss = false;
1378 static const unsigned long long
1380 { return static_cast<unsigned long long>(0); }
1382 static const unsigned long long
1384 { return static_cast<unsigned long long>(0); }
1386 static const unsigned long long
1388 { return static_cast<unsigned long long>(0); }
1390 static const unsigned long long
1392 { return static_cast<unsigned long long>(0); }
1394 static const bool is_iec559 = false;
1395 static const bool is_bounded = true;
1396 static const bool is_modulo = true;
1398 static const bool traps = __glibcxx_integral_traps;
1399 static const bool tinyness_before = false;
1400 static const float_round_style round_style
1401 = round_toward_zero;
1404 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1405 /// numeric_limits<__int128> specialization.
1407 struct numeric_limits<__int128>
1409 static const bool is_specialized = true;
1411 static const __int128
1412 min() { return __glibcxx_min (__int128); }
1414 static const __int128
1415 max() { return __glibcxx_max (__int128); }
1417 #if __cplusplus >= 201103L
1418 static constexpr __int128
1419 lowest() noexcept { return min(); }
1422 static const int digits
1423 = __glibcxx_digits (__int128);
1424 static const int digits10
1425 = __glibcxx_digits10 (__int128);
1426 #if __cplusplus >= 201103L
1427 static constexpr int max_digits10 = 0;
1429 static const bool is_signed = true;
1430 static const bool is_integer = true;
1431 static const bool is_exact = true;
1432 static const int radix = 2;
1434 static const __int128
1435 epsilon() { return 0; }
1437 static const __int128
1438 round_error() { return 0; }
1440 static const int min_exponent = 0;
1441 static const int min_exponent10 = 0;
1442 static const int max_exponent = 0;
1443 static const int max_exponent10 = 0;
1445 static const bool has_infinity = false;
1446 static const bool has_quiet_NaN = false;
1447 static const bool has_signaling_NaN = false;
1448 static const float_denorm_style has_denorm
1450 static const bool has_denorm_loss = false;
1452 static const __int128
1454 { return static_cast<__int128>(0); }
1456 static const __int128
1458 { return static_cast<__int128>(0); }
1460 static const __int128
1462 { return static_cast<__int128>(0); }
1464 static const __int128
1466 { return static_cast<__int128>(0); }
1468 static const bool is_iec559 = false;
1469 static const bool is_bounded = true;
1470 static const bool is_modulo = false;
1472 static const bool traps
1473 = __glibcxx_integral_traps;
1474 static const bool tinyness_before = false;
1475 static const float_round_style round_style
1476 = round_toward_zero;
1479 /// numeric_limits<unsigned __int128> specialization.
1481 struct numeric_limits<unsigned __int128>
1483 static const bool is_specialized = true;
1485 static const unsigned __int128
1488 static const unsigned __int128
1489 max() { return __glibcxx_max (unsigned __int128); }
1491 #if __cplusplus >= 201103L
1492 static constexpr unsigned __int128
1493 lowest() noexcept { return min(); }
1496 static const int digits
1497 = __glibcxx_digits (unsigned __int128);
1498 static const int digits10
1499 = __glibcxx_digits10 (unsigned __int128);
1500 #if __cplusplus >= 201103L
1501 static constexpr int max_digits10 = 0;
1503 static const bool is_signed = false;
1504 static const bool is_integer = true;
1505 static const bool is_exact = true;
1506 static const int radix = 2;
1508 static const unsigned __int128
1509 epsilon() { return 0; }
1511 static const unsigned __int128
1512 round_error() { return 0; }
1514 static const int min_exponent = 0;
1515 static const int min_exponent10 = 0;
1516 static const int max_exponent = 0;
1517 static const int max_exponent10 = 0;
1519 static const bool has_infinity = false;
1520 static const bool has_quiet_NaN = false;
1521 static const bool has_signaling_NaN = false;
1522 static const float_denorm_style has_denorm
1524 static const bool has_denorm_loss = false;
1526 static const unsigned __int128
1528 { return static_cast<unsigned __int128>(0); }
1530 static const unsigned __int128
1532 { return static_cast<unsigned __int128>(0); }
1534 static const unsigned __int128
1536 { return static_cast<unsigned __int128>(0); }
1538 static const unsigned __int128
1540 { return static_cast<unsigned __int128>(0); }
1542 static const bool is_iec559 = false;
1543 static const bool is_bounded = true;
1544 static const bool is_modulo = true;
1546 static const bool traps = __glibcxx_integral_traps;
1547 static const bool tinyness_before = false;
1548 static const float_round_style round_style
1549 = round_toward_zero;
1553 /// numeric_limits<float> specialization.
1555 struct numeric_limits<float>
1557 static const bool is_specialized = true;
1560 min() { return FLT_MIN; }
1563 max() { return FLT_MAX; }
1565 #if __cplusplus >= 201103L
1566 static constexpr float
1567 lowest() noexcept { return -FLT_MAX; }
1570 static const int digits = FLT_MANT_DIG;
1571 static const int digits10 = FLT_DIG;
1572 #if __cplusplus >= 201103L
1573 static constexpr int max_digits10
1574 = __glibcxx_max_digits10 (FLT_MANT_DIG);
1576 static const bool is_signed = true;
1577 static const bool is_integer = false;
1578 static const bool is_exact = false;
1579 static const int radix = FLT_RADIX;
1582 epsilon() { return FLT_EPSILON; }
1585 round_error() { return 0.5F; }
1587 static const int min_exponent = FLT_MIN_EXP;
1588 static const int min_exponent10 = FLT_MIN_10_EXP;
1589 static const int max_exponent = FLT_MAX_EXP;
1590 static const int max_exponent10 = FLT_MAX_10_EXP;
1592 static const bool has_infinity = true;
1593 static const bool has_quiet_NaN = true;
1594 static const bool has_signaling_NaN = false;
1595 static const float_denorm_style has_denorm
1597 static const bool has_denorm_loss
1598 = __glibcxx_float_has_denorm_loss;
1601 infinity() { return HUGE_VALF; }
1604 quiet_NaN() { return nanf(""); }
1607 signaling_NaN() { return nanf(""); }
1610 denorm_min() { return FLT_MIN; }
1612 static const bool is_iec559
1613 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1614 static const bool is_bounded = true;
1615 static const bool is_modulo = false;
1617 static const bool traps = __glibcxx_float_traps;
1618 static const bool tinyness_before
1619 = __glibcxx_float_tinyness_before;
1620 static const float_round_style round_style
1624 #undef __glibcxx_float_has_denorm_loss
1625 #undef __glibcxx_float_traps
1626 #undef __glibcxx_float_tinyness_before
1628 /// numeric_limits<double> specialization.
1630 struct numeric_limits<double>
1632 static const bool is_specialized = true;
1635 min() { return DBL_MIN; }
1638 max() { return DBL_MAX; }
1640 #if __cplusplus >= 201103L
1641 static constexpr double
1642 lowest() noexcept { return -DBL_MAX; }
1645 static const int digits = DBL_MANT_DIG;
1646 static const int digits10 = DBL_DIG;
1647 #if __cplusplus >= 201103L
1648 static constexpr int max_digits10
1649 = __glibcxx_max_digits10 (DBL_MANT_DIG);
1651 static const bool is_signed = true;
1652 static const bool is_integer = false;
1653 static const bool is_exact = false;
1654 static const int radix = FLT_RADIX;
1657 epsilon() { return DBL_EPSILON; }
1660 round_error() { return 0.5; }
1662 static const int min_exponent = DBL_MIN_EXP;
1663 static const int min_exponent10 = DBL_MIN_10_EXP;
1664 static const int max_exponent = DBL_MAX_EXP;
1665 static const int max_exponent10 = DBL_MAX_10_EXP;
1667 static const bool has_infinity = true;
1668 static const bool has_quiet_NaN = true;
1669 static const bool has_signaling_NaN = false;
1670 static const float_denorm_style has_denorm
1672 static const bool has_denorm_loss
1673 = __glibcxx_double_has_denorm_loss;
1676 infinity() { return HUGE_VAL; }
1679 quiet_NaN() { return nan(""); }
1682 signaling_NaN() { return nan(""); }
1685 denorm_min() { return DBL_MIN; }
1687 static const bool is_iec559
1688 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1689 static const bool is_bounded = true;
1690 static const bool is_modulo = false;
1692 static const bool traps = __glibcxx_double_traps;
1693 static const bool tinyness_before
1694 = __glibcxx_double_tinyness_before;
1695 static const float_round_style round_style
1699 #undef __glibcxx_double_has_denorm_loss
1700 #undef __glibcxx_double_traps
1701 #undef __glibcxx_double_tinyness_before
1703 /// numeric_limits<long double> specialization.
1705 struct numeric_limits<long double>
1707 static const bool is_specialized = true;
1709 static const long double
1710 min() { return LDBL_MIN; }
1712 static const long double
1713 max() { return LDBL_MAX; }
1715 #if __cplusplus >= 201103L
1716 static constexpr long double
1717 lowest() noexcept { return -LDBL_MAX; }
1720 static const int digits = LDBL_MANT_DIG;
1721 static const int digits10 = LDBL_DIG;
1722 #if __cplusplus >= 201103L
1723 static const int max_digits10
1724 = __glibcxx_max_digits10 (LDBL_MANT_DIG);
1726 static const bool is_signed = true;
1727 static const bool is_integer = false;
1728 static const bool is_exact = false;
1729 static const int radix = FLT_RADIX;
1731 static const long double
1732 epsilon() { return LDBL_EPSILON; }
1734 static const long double
1735 round_error() { return 0.5L; }
1737 static const int min_exponent = LDBL_MIN_EXP;
1738 static const int min_exponent10 = LDBL_MIN_10_EXP;
1739 static const int max_exponent = LDBL_MAX_EXP;
1740 static const int max_exponent10 = LDBL_MAX_10_EXP;
1742 static const bool has_infinity = true;
1743 static const bool has_quiet_NaN = true;
1744 static const bool has_signaling_NaN = false;
1745 static const float_denorm_style has_denorm
1747 static const bool has_denorm_loss
1748 = __glibcxx_long_double_has_denorm_loss;
1750 static const long double
1751 infinity() { return HUGE_VAL; }
1753 static const long double
1754 quiet_NaN() { return nanl(""); }
1756 static const long double
1757 signaling_NaN() { return nanl(""); }
1759 static const long double
1760 denorm_min() { return LDBL_MIN; }
1762 static const bool is_iec559
1763 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1764 static const bool is_bounded = true;
1765 static const bool is_modulo = false;
1767 static const bool traps = __glibcxx_long_double_traps;
1768 static const bool tinyness_before =
1769 __glibcxx_long_double_tinyness_before;
1770 static const float_round_style round_style =
1774 #undef __glibcxx_long_double_has_denorm_loss
1775 #undef __glibcxx_long_double_traps
1776 #undef __glibcxx_long_double_tinyness_before
1780 #undef __glibcxx_signed
1781 #undef __glibcxx_min
1782 #undef __glibcxx_max
1783 #undef __glibcxx_digits
1784 #undef __glibcxx_digits10
1785 #undef __glibcxx_max_digits10
1787 #endif // _GLIBCXX_NUMERIC_LIMITS