1 // The template and inlines for the numeric_limits classes. -*- C++ -*-
3 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 // 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 2, 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 // You should have received a copy of the GNU General Public License
18 // along with this library; see the file COPYING. If not, write to
19 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 // Boston, MA 02110-1301, USA.
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
32 * This is a Standard C++ Library header.
35 // Note: this is not a conforming implementation.
36 // Written by Gabriel Dos Reis <gdr@codesourcery.com>
43 #ifndef _GLIBCXX_NUMERIC_LIMITS
44 #define _GLIBCXX_NUMERIC_LIMITS 1
46 #pragma GCC system_header
48 #include <bits/c++config.h>
51 // The numeric_limits<> traits document implementation-defined aspects
52 // of fundamental arithmetic data types (integers and floating points).
53 // From Standard C++ point of view, there are 13 such types:
56 // char, signed char, unsigned char (3)
57 // short, unsigned short (2)
59 // long, unsigned long (2)
66 // GNU C++ understands (where supported by the host C-library)
68 // long long, unsigned long long (2)
70 // which brings us to 15 fundamental arithmetic data types in GNU C++.
73 // Since a numeric_limits<> is a bit tricky to get right, we rely on
74 // an interface composed of macros which should be defined in config/os
75 // or config/cpu when they differ from the generic (read arbitrary)
76 // definitions given here.
79 // These values can be overridden in the target configuration file.
80 // The default values are appropriate for many 32-bit targets.
82 // GCC only intrinsically supports modulo integral types. The only remaining
83 // integral exceptional values is division by zero. Only targets that do not
84 // signal division by zero in some "hard to ignore" way should use false.
85 #ifndef __glibcxx_integral_traps
86 # define __glibcxx_integral_traps true
92 // Default values. Should be overridden in configuration files if necessary.
94 #ifndef __glibcxx_float_has_denorm_loss
95 # define __glibcxx_float_has_denorm_loss false
97 #ifndef __glibcxx_float_traps
98 # define __glibcxx_float_traps false
100 #ifndef __glibcxx_float_tinyness_before
101 # define __glibcxx_float_tinyness_before false
106 // Default values. Should be overridden in configuration files if necessary.
108 #ifndef __glibcxx_double_has_denorm_loss
109 # define __glibcxx_double_has_denorm_loss false
111 #ifndef __glibcxx_double_traps
112 # define __glibcxx_double_traps false
114 #ifndef __glibcxx_double_tinyness_before
115 # define __glibcxx_double_tinyness_before false
120 // Default values. Should be overridden in configuration files if necessary.
122 #ifndef __glibcxx_long_double_has_denorm_loss
123 # define __glibcxx_long_double_has_denorm_loss false
125 #ifndef __glibcxx_long_double_traps
126 # define __glibcxx_long_double_traps false
128 #ifndef __glibcxx_long_double_tinyness_before
129 # define __glibcxx_long_double_tinyness_before false
132 // You should not need to define any macros below this point.
134 #define __glibcxx_signed(T) ((T)(-1) < 0)
136 #define __glibcxx_min(T) \
137 (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
139 #define __glibcxx_max(T) \
140 (__glibcxx_signed (T) ? \
141 (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
143 #define __glibcxx_digits(T) \
144 (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
146 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
147 #define __glibcxx_digits10(T) \
148 (__glibcxx_digits (T) * 643 / 2136)
151 _GLIBCXX_BEGIN_NAMESPACE(std)
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, ///< Self-explanatory.
161 round_toward_zero = 0, ///< Self-explanatory.
162 round_to_nearest = 1, ///< To the nearest representable value.
163 round_toward_infinity = 2, ///< Self-explanatory.
164 round_toward_neg_infinity = 3 ///< Self-explanatory.
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;
203 /** The number of base 10 digits that can be represented without change. */
204 static const int digits10 = 0;
205 /** True if the type is signed. */
206 static const bool is_signed = false;
207 /** True if the type is integer.
208 * Is this supposed to be "if the type is integral"?
210 static const bool is_integer = false;
211 /** True if the type uses an exact representation. "All integer types are
212 exact, but not all exact types are integer. For example, rational and
213 fixed-exponent representations are exact but not integer."
215 static const bool is_exact = false;
216 /** For integer types, specifies the base of the representation. For
217 floating types, specifies the base of the exponent representation. */
218 static const int radix = 0;
220 /** The minimum negative integer such that @c radix raised to the power of
221 (one less than that integer) is a normalized floating point number. */
222 static const int min_exponent = 0;
223 /** The minimum negative integer such that 10 raised to that power is in
224 the range of normalized floating point numbers. */
225 static const int min_exponent10 = 0;
226 /** The maximum positive integer such that @c radix raised to the power of
227 (one less than that integer) is a representable finite floating point
229 static const int max_exponent = 0;
230 /** The maximum positive integer such that 10 raised to that power is in
231 the range of representable finite floating point numbers. */
232 static const int max_exponent10 = 0;
234 /** True if the type has a representation for positive infinity. */
235 static const bool has_infinity = false;
236 /** True if the type has a representation for a quiet (non-signaling)
238 static const bool has_quiet_NaN = false;
239 /** True if the type has a representation for a signaling
241 static const bool has_signaling_NaN = false;
242 /** See std::float_denorm_style for more information. */
243 static const float_denorm_style has_denorm = denorm_absent;
244 /** "True if loss of accuracy is detected as a denormalization loss,
245 rather than as an inexact result." [18.2.1.2]/42 */
246 static const bool has_denorm_loss = false;
248 /** True if-and-only-if the type adheres to the IEC 559 standard, also
249 known as IEEE 754. (Only makes sense for floating point types.) */
250 static const bool is_iec559 = false;
251 /** "True if the set of values representable by the type is finite. All
252 built-in types are bounded, this member would be false for arbitrary
253 precision types." [18.2.1.2]/54 */
254 static const bool is_bounded = false;
255 /** True if the type is @e modulo, that is, if it is possible to add two
256 positive numbers and have a result that wraps around to a third number
257 that is less. Typically false for floating types, true for unsigned
258 integers, and true for signed integers. */
259 static const bool is_modulo = false;
261 /** True if trapping is implemented for this type. */
262 static const bool traps = false;
263 /** True if tininess is detected before rounding. (see IEC 559) */
264 static const bool tinyness_before = false;
265 /** See std::float_round_style for more information. This is only
266 meaningful for floating types; integer types will all be
267 round_toward_zero. */
268 static const float_round_style round_style = round_toward_zero;
272 * @brief Properties of fundamental types.
274 * This class allows a program to obtain information about the
275 * representation of a fundamental type on a given platform. For
276 * non-fundamental types, the functions will return 0 and the data
277 * members will all be @c false.
279 * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
280 * noted, but not incorporated in this documented (yet).
282 template<typename _Tp>
283 struct numeric_limits : public __numeric_limits_base
285 /** The minimum finite value, or for floating types with
286 denormalization, the minimum positive normalized value. */
287 static _Tp min() throw() { return static_cast<_Tp>(0); }
288 /** The maximum finite value. */
289 static _Tp max() throw() { return static_cast<_Tp>(0); }
290 /** The @e machine @e epsilon: the difference between 1 and the least
291 value greater than 1 that is representable. */
292 static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
293 /** The maximum rounding error measurement (see LIA-1). */
294 static _Tp round_error() throw() { return static_cast<_Tp>(0); }
295 /** The representation of positive infinity, if @c has_infinity. */
296 static _Tp infinity() throw() { return static_cast<_Tp>(0); }
297 /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */
298 static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
299 /** The representation of a signaling "Not a Number," if
300 @c has_signaling_NaN. */
301 static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
302 /** The minimum positive denormalized value. For types where
303 @c has_denorm is false, this is the minimum positive normalized
305 static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
308 // Now there follow 15 explicit specializations. Yes, 15. Make sure
309 // you get the count right.
311 /// numeric_limits<bool> specialization.
313 struct numeric_limits<bool>
315 static const bool is_specialized = true;
317 static bool min() throw()
319 static bool max() throw()
322 static const int digits = 1;
323 static const int digits10 = 0;
324 static const bool is_signed = false;
325 static const bool is_integer = true;
326 static const bool is_exact = true;
327 static const int radix = 2;
328 static bool epsilon() throw()
330 static bool round_error() throw()
333 static const int min_exponent = 0;
334 static const int min_exponent10 = 0;
335 static const int max_exponent = 0;
336 static const int max_exponent10 = 0;
338 static const bool has_infinity = false;
339 static const bool has_quiet_NaN = false;
340 static const bool has_signaling_NaN = false;
341 static const float_denorm_style has_denorm = denorm_absent;
342 static const bool has_denorm_loss = false;
344 static bool infinity() throw()
346 static bool quiet_NaN() throw()
348 static bool signaling_NaN() throw()
350 static bool denorm_min() throw()
353 static const bool is_iec559 = false;
354 static const bool is_bounded = true;
355 static const bool is_modulo = false;
357 // It is not clear what it means for a boolean type to trap.
358 // This is a DR on the LWG issue list. Here, I use integer
359 // promotion semantics.
360 static const bool traps = __glibcxx_integral_traps;
361 static const bool tinyness_before = false;
362 static const float_round_style round_style = round_toward_zero;
365 /// numeric_limits<char> specialization.
367 struct numeric_limits<char>
369 static const bool is_specialized = true;
371 static char min() throw()
372 { return __glibcxx_min(char); }
373 static char max() throw()
374 { return __glibcxx_max(char); }
376 static const int digits = __glibcxx_digits (char);
377 static const int digits10 = __glibcxx_digits10 (char);
378 static const bool is_signed = __glibcxx_signed (char);
379 static const bool is_integer = true;
380 static const bool is_exact = true;
381 static const int radix = 2;
382 static char epsilon() throw()
384 static char round_error() throw()
387 static const int min_exponent = 0;
388 static const int min_exponent10 = 0;
389 static const int max_exponent = 0;
390 static const int max_exponent10 = 0;
392 static const bool has_infinity = false;
393 static const bool has_quiet_NaN = false;
394 static const bool has_signaling_NaN = false;
395 static const float_denorm_style has_denorm = denorm_absent;
396 static const bool has_denorm_loss = false;
398 static char infinity() throw()
400 static char quiet_NaN() throw()
402 static char signaling_NaN() throw()
404 static char denorm_min() throw()
405 { return static_cast<char>(0); }
407 static const bool is_iec559 = false;
408 static const bool is_bounded = true;
409 static const bool is_modulo = true;
411 static const bool traps = __glibcxx_integral_traps;
412 static const bool tinyness_before = false;
413 static const float_round_style round_style = round_toward_zero;
416 /// numeric_limits<signed char> specialization.
418 struct numeric_limits<signed char>
420 static const bool is_specialized = true;
422 static signed char min() throw()
423 { return -__SCHAR_MAX__ - 1; }
424 static signed char max() throw()
425 { return __SCHAR_MAX__; }
427 static const int digits = __glibcxx_digits (signed char);
428 static const int digits10 = __glibcxx_digits10 (signed char);
429 static const bool is_signed = true;
430 static const bool is_integer = true;
431 static const bool is_exact = true;
432 static const int radix = 2;
433 static signed char epsilon() throw()
435 static signed char round_error() throw()
438 static const int min_exponent = 0;
439 static const int min_exponent10 = 0;
440 static const int max_exponent = 0;
441 static const int max_exponent10 = 0;
443 static const bool has_infinity = false;
444 static const bool has_quiet_NaN = false;
445 static const bool has_signaling_NaN = false;
446 static const float_denorm_style has_denorm = denorm_absent;
447 static const bool has_denorm_loss = false;
449 static signed char infinity() throw()
450 { return static_cast<signed char>(0); }
451 static signed char quiet_NaN() throw()
452 { return static_cast<signed char>(0); }
453 static signed char signaling_NaN() throw()
454 { return static_cast<signed char>(0); }
455 static signed char denorm_min() throw()
456 { return static_cast<signed char>(0); }
458 static const bool is_iec559 = false;
459 static const bool is_bounded = true;
460 static const bool is_modulo = true;
462 static const bool traps = __glibcxx_integral_traps;
463 static const bool tinyness_before = false;
464 static const float_round_style round_style = round_toward_zero;
467 /// numeric_limits<unsigned char> specialization.
469 struct numeric_limits<unsigned char>
471 static const bool is_specialized = true;
473 static unsigned char min() throw()
475 static unsigned char max() throw()
476 { return __SCHAR_MAX__ * 2U + 1; }
478 static const int digits = __glibcxx_digits (unsigned char);
479 static const int digits10 = __glibcxx_digits10 (unsigned char);
480 static const bool is_signed = false;
481 static const bool is_integer = true;
482 static const bool is_exact = true;
483 static const int radix = 2;
484 static unsigned char epsilon() throw()
486 static unsigned char round_error() throw()
489 static const int min_exponent = 0;
490 static const int min_exponent10 = 0;
491 static const int max_exponent = 0;
492 static const int max_exponent10 = 0;
494 static const bool has_infinity = false;
495 static const bool has_quiet_NaN = false;
496 static const bool has_signaling_NaN = false;
497 static const float_denorm_style has_denorm = denorm_absent;
498 static const bool has_denorm_loss = false;
500 static unsigned char infinity() throw()
501 { return static_cast<unsigned char>(0); }
502 static unsigned char quiet_NaN() throw()
503 { return static_cast<unsigned char>(0); }
504 static unsigned char signaling_NaN() throw()
505 { return static_cast<unsigned char>(0); }
506 static unsigned char denorm_min() throw()
507 { return static_cast<unsigned char>(0); }
509 static const bool is_iec559 = false;
510 static const bool is_bounded = true;
511 static const bool is_modulo = true;
513 static const bool traps = __glibcxx_integral_traps;
514 static const bool tinyness_before = false;
515 static const float_round_style round_style = round_toward_zero;
518 /// numeric_limits<wchar_t> specialization.
520 struct numeric_limits<wchar_t>
522 static const bool is_specialized = true;
524 static wchar_t min() throw()
525 { return __glibcxx_min (wchar_t); }
526 static wchar_t max() throw()
527 { return __glibcxx_max (wchar_t); }
529 static const int digits = __glibcxx_digits (wchar_t);
530 static const int digits10 = __glibcxx_digits10 (wchar_t);
531 static const bool is_signed = __glibcxx_signed (wchar_t);
532 static const bool is_integer = true;
533 static const bool is_exact = true;
534 static const int radix = 2;
535 static wchar_t epsilon() throw()
537 static wchar_t round_error() throw()
540 static const int min_exponent = 0;
541 static const int min_exponent10 = 0;
542 static const int max_exponent = 0;
543 static const int max_exponent10 = 0;
545 static const bool has_infinity = false;
546 static const bool has_quiet_NaN = false;
547 static const bool has_signaling_NaN = false;
548 static const float_denorm_style has_denorm = denorm_absent;
549 static const bool has_denorm_loss = false;
551 static wchar_t infinity() throw()
552 { return wchar_t(); }
553 static wchar_t quiet_NaN() throw()
554 { return wchar_t(); }
555 static wchar_t signaling_NaN() throw()
556 { return wchar_t(); }
557 static wchar_t denorm_min() throw()
558 { return wchar_t(); }
560 static const bool is_iec559 = false;
561 static const bool is_bounded = true;
562 static const bool is_modulo = true;
564 static const bool traps = __glibcxx_integral_traps;
565 static const bool tinyness_before = false;
566 static const float_round_style round_style = round_toward_zero;
569 #ifdef __GXX_EXPERIMENTAL_CXX0X__
570 /// numeric_limits<char16_t> specialization.
572 struct numeric_limits<char16_t>
574 static const bool is_specialized = true;
576 static char16_t min() throw()
577 { return __glibcxx_min (char16_t); }
578 static char16_t max() throw()
579 { return __glibcxx_max (char16_t); }
581 static const int digits = __glibcxx_digits (char16_t);
582 static const int digits10 = __glibcxx_digits10 (char16_t);
583 static const bool is_signed = __glibcxx_signed (char16_t);
584 static const bool is_integer = true;
585 static const bool is_exact = true;
586 static const int radix = 2;
587 static char16_t epsilon() throw()
589 static char16_t round_error() throw()
592 static const int min_exponent = 0;
593 static const int min_exponent10 = 0;
594 static const int max_exponent = 0;
595 static const int max_exponent10 = 0;
597 static const bool has_infinity = false;
598 static const bool has_quiet_NaN = false;
599 static const bool has_signaling_NaN = false;
600 static const float_denorm_style has_denorm = denorm_absent;
601 static const bool has_denorm_loss = false;
603 static char16_t infinity() throw()
604 { return char16_t(); }
605 static char16_t quiet_NaN() throw()
606 { return char16_t(); }
607 static char16_t signaling_NaN() throw()
608 { return char16_t(); }
609 static char16_t denorm_min() throw()
610 { return char16_t(); }
612 static const bool is_iec559 = false;
613 static const bool is_bounded = true;
614 static const bool is_modulo = true;
616 static const bool traps = __glibcxx_integral_traps;
617 static const bool tinyness_before = false;
618 static const float_round_style round_style = round_toward_zero;
621 /// numeric_limits<char32_t> specialization.
623 struct numeric_limits<char32_t>
625 static const bool is_specialized = true;
627 static char32_t min() throw()
628 { return __glibcxx_min (char32_t); }
629 static char32_t max() throw()
630 { return __glibcxx_max (char32_t); }
632 static const int digits = __glibcxx_digits (char32_t);
633 static const int digits10 = __glibcxx_digits10 (char32_t);
634 static const bool is_signed = __glibcxx_signed (char32_t);
635 static const bool is_integer = true;
636 static const bool is_exact = true;
637 static const int radix = 2;
638 static char32_t epsilon() throw()
640 static char32_t round_error() throw()
643 static const int min_exponent = 0;
644 static const int min_exponent10 = 0;
645 static const int max_exponent = 0;
646 static const int max_exponent10 = 0;
648 static const bool has_infinity = false;
649 static const bool has_quiet_NaN = false;
650 static const bool has_signaling_NaN = false;
651 static const float_denorm_style has_denorm = denorm_absent;
652 static const bool has_denorm_loss = false;
654 static char32_t infinity() throw()
655 { return char32_t(); }
656 static char32_t quiet_NaN() throw()
657 { return char32_t(); }
658 static char32_t signaling_NaN() throw()
659 { return char32_t(); }
660 static char32_t denorm_min() throw()
661 { return char32_t(); }
663 static const bool is_iec559 = false;
664 static const bool is_bounded = true;
665 static const bool is_modulo = true;
667 static const bool traps = __glibcxx_integral_traps;
668 static const bool tinyness_before = false;
669 static const float_round_style round_style = round_toward_zero;
673 /// numeric_limits<short> specialization.
675 struct numeric_limits<short>
677 static const bool is_specialized = true;
679 static short min() throw()
680 { return -__SHRT_MAX__ - 1; }
681 static short max() throw()
682 { return __SHRT_MAX__; }
684 static const int digits = __glibcxx_digits (short);
685 static const int digits10 = __glibcxx_digits10 (short);
686 static const bool is_signed = true;
687 static const bool is_integer = true;
688 static const bool is_exact = true;
689 static const int radix = 2;
690 static short epsilon() throw()
692 static short round_error() throw()
695 static const int min_exponent = 0;
696 static const int min_exponent10 = 0;
697 static const int max_exponent = 0;
698 static const int max_exponent10 = 0;
700 static const bool has_infinity = false;
701 static const bool has_quiet_NaN = false;
702 static const bool has_signaling_NaN = false;
703 static const float_denorm_style has_denorm = denorm_absent;
704 static const bool has_denorm_loss = false;
706 static short infinity() throw()
708 static short quiet_NaN() throw()
710 static short signaling_NaN() throw()
712 static short denorm_min() throw()
715 static const bool is_iec559 = false;
716 static const bool is_bounded = true;
717 static const bool is_modulo = true;
719 static const bool traps = __glibcxx_integral_traps;
720 static const bool tinyness_before = false;
721 static const float_round_style round_style = round_toward_zero;
724 /// numeric_limits<unsigned short> specialization.
726 struct numeric_limits<unsigned short>
728 static const bool is_specialized = true;
730 static unsigned short min() throw()
732 static unsigned short max() throw()
733 { return __SHRT_MAX__ * 2U + 1; }
735 static const int digits = __glibcxx_digits (unsigned short);
736 static const int digits10 = __glibcxx_digits10 (unsigned short);
737 static const bool is_signed = false;
738 static const bool is_integer = true;
739 static const bool is_exact = true;
740 static const int radix = 2;
741 static unsigned short epsilon() throw()
743 static unsigned short round_error() throw()
746 static const int min_exponent = 0;
747 static const int min_exponent10 = 0;
748 static const int max_exponent = 0;
749 static const int max_exponent10 = 0;
751 static const bool has_infinity = false;
752 static const bool has_quiet_NaN = false;
753 static const bool has_signaling_NaN = false;
754 static const float_denorm_style has_denorm = denorm_absent;
755 static const bool has_denorm_loss = false;
757 static unsigned short infinity() throw()
758 { return static_cast<unsigned short>(0); }
759 static unsigned short quiet_NaN() throw()
760 { return static_cast<unsigned short>(0); }
761 static unsigned short signaling_NaN() throw()
762 { return static_cast<unsigned short>(0); }
763 static unsigned short denorm_min() throw()
764 { return static_cast<unsigned short>(0); }
766 static const bool is_iec559 = false;
767 static const bool is_bounded = true;
768 static const bool is_modulo = true;
770 static const bool traps = __glibcxx_integral_traps;
771 static const bool tinyness_before = false;
772 static const float_round_style round_style = round_toward_zero;
775 /// numeric_limits<int> specialization.
777 struct numeric_limits<int>
779 static const bool is_specialized = true;
781 static int min() throw()
782 { return -__INT_MAX__ - 1; }
783 static int max() throw()
784 { return __INT_MAX__; }
786 static const int digits = __glibcxx_digits (int);
787 static const int digits10 = __glibcxx_digits10 (int);
788 static const bool is_signed = true;
789 static const bool is_integer = true;
790 static const bool is_exact = true;
791 static const int radix = 2;
792 static int epsilon() throw()
794 static int round_error() throw()
797 static const int min_exponent = 0;
798 static const int min_exponent10 = 0;
799 static const int max_exponent = 0;
800 static const int max_exponent10 = 0;
802 static const bool has_infinity = false;
803 static const bool has_quiet_NaN = false;
804 static const bool has_signaling_NaN = false;
805 static const float_denorm_style has_denorm = denorm_absent;
806 static const bool has_denorm_loss = false;
808 static int infinity() throw()
809 { return static_cast<int>(0); }
810 static int quiet_NaN() throw()
811 { return static_cast<int>(0); }
812 static int signaling_NaN() throw()
813 { return static_cast<int>(0); }
814 static int denorm_min() throw()
815 { return static_cast<int>(0); }
817 static const bool is_iec559 = false;
818 static const bool is_bounded = true;
819 static const bool is_modulo = true;
821 static const bool traps = __glibcxx_integral_traps;
822 static const bool tinyness_before = false;
823 static const float_round_style round_style = round_toward_zero;
826 /// numeric_limits<unsigned int> specialization.
828 struct numeric_limits<unsigned int>
830 static const bool is_specialized = true;
832 static unsigned int min() throw()
834 static unsigned int max() throw()
835 { return __INT_MAX__ * 2U + 1; }
837 static const int digits = __glibcxx_digits (unsigned int);
838 static const int digits10 = __glibcxx_digits10 (unsigned int);
839 static const bool is_signed = false;
840 static const bool is_integer = true;
841 static const bool is_exact = true;
842 static const int radix = 2;
843 static unsigned int epsilon() throw()
845 static unsigned int round_error() throw()
848 static const int min_exponent = 0;
849 static const int min_exponent10 = 0;
850 static const int max_exponent = 0;
851 static const int max_exponent10 = 0;
853 static const bool has_infinity = false;
854 static const bool has_quiet_NaN = false;
855 static const bool has_signaling_NaN = false;
856 static const float_denorm_style has_denorm = denorm_absent;
857 static const bool has_denorm_loss = false;
859 static unsigned int infinity() throw()
860 { return static_cast<unsigned int>(0); }
861 static unsigned int quiet_NaN() throw()
862 { return static_cast<unsigned int>(0); }
863 static unsigned int signaling_NaN() throw()
864 { return static_cast<unsigned int>(0); }
865 static unsigned int denorm_min() throw()
866 { return static_cast<unsigned int>(0); }
868 static const bool is_iec559 = false;
869 static const bool is_bounded = true;
870 static const bool is_modulo = true;
872 static const bool traps = __glibcxx_integral_traps;
873 static const bool tinyness_before = false;
874 static const float_round_style round_style = round_toward_zero;
877 /// numeric_limits<long> specialization.
879 struct numeric_limits<long>
881 static const bool is_specialized = true;
883 static long min() throw()
884 { return -__LONG_MAX__ - 1; }
885 static long max() throw()
886 { return __LONG_MAX__; }
888 static const int digits = __glibcxx_digits (long);
889 static const int digits10 = __glibcxx_digits10 (long);
890 static const bool is_signed = true;
891 static const bool is_integer = true;
892 static const bool is_exact = true;
893 static const int radix = 2;
894 static long epsilon() throw()
896 static long round_error() throw()
899 static const int min_exponent = 0;
900 static const int min_exponent10 = 0;
901 static const int max_exponent = 0;
902 static const int max_exponent10 = 0;
904 static const bool has_infinity = false;
905 static const bool has_quiet_NaN = false;
906 static const bool has_signaling_NaN = false;
907 static const float_denorm_style has_denorm = denorm_absent;
908 static const bool has_denorm_loss = false;
910 static long infinity() throw()
911 { return static_cast<long>(0); }
912 static long quiet_NaN() throw()
913 { return static_cast<long>(0); }
914 static long signaling_NaN() throw()
915 { return static_cast<long>(0); }
916 static long denorm_min() throw()
917 { return static_cast<long>(0); }
919 static const bool is_iec559 = false;
920 static const bool is_bounded = true;
921 static const bool is_modulo = true;
923 static const bool traps = __glibcxx_integral_traps;
924 static const bool tinyness_before = false;
925 static const float_round_style round_style = round_toward_zero;
928 /// numeric_limits<unsigned long> specialization.
930 struct numeric_limits<unsigned long>
932 static const bool is_specialized = true;
934 static unsigned long min() throw()
936 static unsigned long max() throw()
937 { return __LONG_MAX__ * 2UL + 1; }
939 static const int digits = __glibcxx_digits (unsigned long);
940 static const int digits10 = __glibcxx_digits10 (unsigned long);
941 static const bool is_signed = false;
942 static const bool is_integer = true;
943 static const bool is_exact = true;
944 static const int radix = 2;
945 static unsigned long epsilon() throw()
947 static unsigned long round_error() throw()
950 static const int min_exponent = 0;
951 static const int min_exponent10 = 0;
952 static const int max_exponent = 0;
953 static const int max_exponent10 = 0;
955 static const bool has_infinity = false;
956 static const bool has_quiet_NaN = false;
957 static const bool has_signaling_NaN = false;
958 static const float_denorm_style has_denorm = denorm_absent;
959 static const bool has_denorm_loss = false;
961 static unsigned long infinity() throw()
962 { return static_cast<unsigned long>(0); }
963 static unsigned long quiet_NaN() throw()
964 { return static_cast<unsigned long>(0); }
965 static unsigned long signaling_NaN() throw()
966 { return static_cast<unsigned long>(0); }
967 static unsigned long denorm_min() throw()
968 { return static_cast<unsigned long>(0); }
970 static const bool is_iec559 = false;
971 static const bool is_bounded = true;
972 static const bool is_modulo = true;
974 static const bool traps = __glibcxx_integral_traps;
975 static const bool tinyness_before = false;
976 static const float_round_style round_style = round_toward_zero;
979 /// numeric_limits<long long> specialization.
981 struct numeric_limits<long long>
983 static const bool is_specialized = true;
985 static long long min() throw()
986 { return -__LONG_LONG_MAX__ - 1; }
987 static long long max() throw()
988 { return __LONG_LONG_MAX__; }
990 static const int digits = __glibcxx_digits (long long);
991 static const int digits10 = __glibcxx_digits10 (long long);
992 static const bool is_signed = true;
993 static const bool is_integer = true;
994 static const bool is_exact = true;
995 static const int radix = 2;
996 static long long epsilon() throw()
998 static long long round_error() throw()
1001 static const int min_exponent = 0;
1002 static const int min_exponent10 = 0;
1003 static const int max_exponent = 0;
1004 static const int max_exponent10 = 0;
1006 static const bool has_infinity = false;
1007 static const bool has_quiet_NaN = false;
1008 static const bool has_signaling_NaN = false;
1009 static const float_denorm_style has_denorm = denorm_absent;
1010 static const bool has_denorm_loss = false;
1012 static long long infinity() throw()
1013 { return static_cast<long long>(0); }
1014 static long long quiet_NaN() throw()
1015 { return static_cast<long long>(0); }
1016 static long long signaling_NaN() throw()
1017 { return static_cast<long long>(0); }
1018 static long long denorm_min() throw()
1019 { return static_cast<long long>(0); }
1021 static const bool is_iec559 = false;
1022 static const bool is_bounded = true;
1023 static const bool is_modulo = true;
1025 static const bool traps = __glibcxx_integral_traps;
1026 static const bool tinyness_before = false;
1027 static const float_round_style round_style = round_toward_zero;
1030 /// numeric_limits<unsigned long long> specialization.
1032 struct numeric_limits<unsigned long long>
1034 static const bool is_specialized = true;
1036 static unsigned long long min() throw()
1038 static unsigned long long max() throw()
1039 { return __LONG_LONG_MAX__ * 2ULL + 1; }
1041 static const int digits = __glibcxx_digits (unsigned long long);
1042 static const int digits10 = __glibcxx_digits10 (unsigned long long);
1043 static const bool is_signed = false;
1044 static const bool is_integer = true;
1045 static const bool is_exact = true;
1046 static const int radix = 2;
1047 static unsigned long long epsilon() throw()
1049 static unsigned long long round_error() throw()
1052 static const int min_exponent = 0;
1053 static const int min_exponent10 = 0;
1054 static const int max_exponent = 0;
1055 static const int max_exponent10 = 0;
1057 static const bool has_infinity = false;
1058 static const bool has_quiet_NaN = false;
1059 static const bool has_signaling_NaN = false;
1060 static const float_denorm_style has_denorm = denorm_absent;
1061 static const bool has_denorm_loss = false;
1063 static unsigned long long infinity() throw()
1064 { return static_cast<unsigned long long>(0); }
1065 static unsigned long long quiet_NaN() throw()
1066 { return static_cast<unsigned long long>(0); }
1067 static unsigned long long signaling_NaN() throw()
1068 { return static_cast<unsigned long long>(0); }
1069 static unsigned long long denorm_min() throw()
1070 { return static_cast<unsigned long long>(0); }
1072 static const bool is_iec559 = false;
1073 static const bool is_bounded = true;
1074 static const bool is_modulo = true;
1076 static const bool traps = __glibcxx_integral_traps;
1077 static const bool tinyness_before = false;
1078 static const float_round_style round_style = round_toward_zero;
1081 /// numeric_limits<float> specialization.
1083 struct numeric_limits<float>
1085 static const bool is_specialized = true;
1087 static float min() throw()
1088 { return __FLT_MIN__; }
1089 static float max() throw()
1090 { return __FLT_MAX__; }
1092 static const int digits = __FLT_MANT_DIG__;
1093 static const int digits10 = __FLT_DIG__;
1094 static const bool is_signed = true;
1095 static const bool is_integer = false;
1096 static const bool is_exact = false;
1097 static const int radix = __FLT_RADIX__;
1098 static float epsilon() throw()
1099 { return __FLT_EPSILON__; }
1100 static float round_error() throw()
1103 static const int min_exponent = __FLT_MIN_EXP__;
1104 static const int min_exponent10 = __FLT_MIN_10_EXP__;
1105 static const int max_exponent = __FLT_MAX_EXP__;
1106 static const int max_exponent10 = __FLT_MAX_10_EXP__;
1108 static const bool has_infinity = __FLT_HAS_INFINITY__;
1109 static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
1110 static const bool has_signaling_NaN = has_quiet_NaN;
1111 static const float_denorm_style has_denorm
1112 = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
1113 static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
1115 static float infinity() throw()
1116 { return __builtin_huge_valf (); }
1117 static float quiet_NaN() throw()
1118 { return __builtin_nanf (""); }
1119 static float signaling_NaN() throw()
1120 { return __builtin_nansf (""); }
1121 static float denorm_min() throw()
1122 { return __FLT_DENORM_MIN__; }
1124 static const bool is_iec559
1125 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1126 static const bool is_bounded = true;
1127 static const bool is_modulo = false;
1129 static const bool traps = __glibcxx_float_traps;
1130 static const bool tinyness_before = __glibcxx_float_tinyness_before;
1131 static const float_round_style round_style = round_to_nearest;
1134 #undef __glibcxx_float_has_denorm_loss
1135 #undef __glibcxx_float_traps
1136 #undef __glibcxx_float_tinyness_before
1138 /// numeric_limits<double> specialization.
1140 struct numeric_limits<double>
1142 static const bool is_specialized = true;
1144 static double min() throw()
1145 { return __DBL_MIN__; }
1146 static double max() throw()
1147 { return __DBL_MAX__; }
1149 static const int digits = __DBL_MANT_DIG__;
1150 static const int digits10 = __DBL_DIG__;
1151 static const bool is_signed = true;
1152 static const bool is_integer = false;
1153 static const bool is_exact = false;
1154 static const int radix = __FLT_RADIX__;
1155 static double epsilon() throw()
1156 { return __DBL_EPSILON__; }
1157 static double round_error() throw()
1160 static const int min_exponent = __DBL_MIN_EXP__;
1161 static const int min_exponent10 = __DBL_MIN_10_EXP__;
1162 static const int max_exponent = __DBL_MAX_EXP__;
1163 static const int max_exponent10 = __DBL_MAX_10_EXP__;
1165 static const bool has_infinity = __DBL_HAS_INFINITY__;
1166 static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
1167 static const bool has_signaling_NaN = has_quiet_NaN;
1168 static const float_denorm_style has_denorm
1169 = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1170 static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
1172 static double infinity() throw()
1173 { return __builtin_huge_val(); }
1174 static double quiet_NaN() throw()
1175 { return __builtin_nan (""); }
1176 static double signaling_NaN() throw()
1177 { return __builtin_nans (""); }
1178 static double denorm_min() throw()
1179 { return __DBL_DENORM_MIN__; }
1181 static const bool is_iec559
1182 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1183 static const bool is_bounded = true;
1184 static const bool is_modulo = false;
1186 static const bool traps = __glibcxx_double_traps;
1187 static const bool tinyness_before = __glibcxx_double_tinyness_before;
1188 static const float_round_style round_style = round_to_nearest;
1191 #undef __glibcxx_double_has_denorm_loss
1192 #undef __glibcxx_double_traps
1193 #undef __glibcxx_double_tinyness_before
1195 /// numeric_limits<long double> specialization.
1197 struct numeric_limits<long double>
1199 static const bool is_specialized = true;
1201 static long double min() throw()
1202 { return __LDBL_MIN__; }
1203 static long double max() throw()
1204 { return __LDBL_MAX__; }
1206 static const int digits = __LDBL_MANT_DIG__;
1207 static const int digits10 = __LDBL_DIG__;
1208 static const bool is_signed = true;
1209 static const bool is_integer = false;
1210 static const bool is_exact = false;
1211 static const int radix = __FLT_RADIX__;
1212 static long double epsilon() throw()
1213 { return __LDBL_EPSILON__; }
1214 static long double round_error() throw()
1217 static const int min_exponent = __LDBL_MIN_EXP__;
1218 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
1219 static const int max_exponent = __LDBL_MAX_EXP__;
1220 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
1222 static const bool has_infinity = __LDBL_HAS_INFINITY__;
1223 static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
1224 static const bool has_signaling_NaN = has_quiet_NaN;
1225 static const float_denorm_style has_denorm
1226 = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1227 static const bool has_denorm_loss
1228 = __glibcxx_long_double_has_denorm_loss;
1230 static long double infinity() throw()
1231 { return __builtin_huge_vall (); }
1232 static long double quiet_NaN() throw()
1233 { return __builtin_nanl (""); }
1234 static long double signaling_NaN() throw()
1235 { return __builtin_nansl (""); }
1236 static long double denorm_min() throw()
1237 { return __LDBL_DENORM_MIN__; }
1239 static const bool is_iec559
1240 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1241 static const bool is_bounded = true;
1242 static const bool is_modulo = false;
1244 static const bool traps = __glibcxx_long_double_traps;
1245 static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
1246 static const float_round_style round_style = round_to_nearest;
1249 #undef __glibcxx_long_double_has_denorm_loss
1250 #undef __glibcxx_long_double_traps
1251 #undef __glibcxx_long_double_tinyness_before
1253 _GLIBCXX_END_NAMESPACE
1255 #undef __glibcxx_signed
1256 #undef __glibcxx_min
1257 #undef __glibcxx_max
1258 #undef __glibcxx_digits
1259 #undef __glibcxx_digits10
1261 #endif // _GLIBCXX_NUMERIC_LIMITS