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 /// numeric_limits<short> specialization.
571 struct numeric_limits<short>
573 static const bool is_specialized = true;
575 static short min() throw()
576 { return -__SHRT_MAX__ - 1; }
577 static short max() throw()
578 { return __SHRT_MAX__; }
580 static const int digits = __glibcxx_digits (short);
581 static const int digits10 = __glibcxx_digits10 (short);
582 static const bool is_signed = true;
583 static const bool is_integer = true;
584 static const bool is_exact = true;
585 static const int radix = 2;
586 static short epsilon() throw()
588 static short round_error() throw()
591 static const int min_exponent = 0;
592 static const int min_exponent10 = 0;
593 static const int max_exponent = 0;
594 static const int max_exponent10 = 0;
596 static const bool has_infinity = false;
597 static const bool has_quiet_NaN = false;
598 static const bool has_signaling_NaN = false;
599 static const float_denorm_style has_denorm = denorm_absent;
600 static const bool has_denorm_loss = false;
602 static short infinity() throw()
604 static short quiet_NaN() throw()
606 static short signaling_NaN() throw()
608 static short denorm_min() throw()
611 static const bool is_iec559 = false;
612 static const bool is_bounded = true;
613 static const bool is_modulo = true;
615 static const bool traps = __glibcxx_integral_traps;
616 static const bool tinyness_before = false;
617 static const float_round_style round_style = round_toward_zero;
620 /// numeric_limits<unsigned short> specialization.
622 struct numeric_limits<unsigned short>
624 static const bool is_specialized = true;
626 static unsigned short min() throw()
628 static unsigned short max() throw()
629 { return __SHRT_MAX__ * 2U + 1; }
631 static const int digits = __glibcxx_digits (unsigned short);
632 static const int digits10 = __glibcxx_digits10 (unsigned short);
633 static const bool is_signed = false;
634 static const bool is_integer = true;
635 static const bool is_exact = true;
636 static const int radix = 2;
637 static unsigned short epsilon() throw()
639 static unsigned short round_error() throw()
642 static const int min_exponent = 0;
643 static const int min_exponent10 = 0;
644 static const int max_exponent = 0;
645 static const int max_exponent10 = 0;
647 static const bool has_infinity = false;
648 static const bool has_quiet_NaN = false;
649 static const bool has_signaling_NaN = false;
650 static const float_denorm_style has_denorm = denorm_absent;
651 static const bool has_denorm_loss = false;
653 static unsigned short infinity() throw()
654 { return static_cast<unsigned short>(0); }
655 static unsigned short quiet_NaN() throw()
656 { return static_cast<unsigned short>(0); }
657 static unsigned short signaling_NaN() throw()
658 { return static_cast<unsigned short>(0); }
659 static unsigned short denorm_min() throw()
660 { return static_cast<unsigned short>(0); }
662 static const bool is_iec559 = false;
663 static const bool is_bounded = true;
664 static const bool is_modulo = true;
666 static const bool traps = __glibcxx_integral_traps;
667 static const bool tinyness_before = false;
668 static const float_round_style round_style = round_toward_zero;
671 /// numeric_limits<int> specialization.
673 struct numeric_limits<int>
675 static const bool is_specialized = true;
677 static int min() throw()
678 { return -__INT_MAX__ - 1; }
679 static int max() throw()
680 { return __INT_MAX__; }
682 static const int digits = __glibcxx_digits (int);
683 static const int digits10 = __glibcxx_digits10 (int);
684 static const bool is_signed = true;
685 static const bool is_integer = true;
686 static const bool is_exact = true;
687 static const int radix = 2;
688 static int epsilon() throw()
690 static int round_error() throw()
693 static const int min_exponent = 0;
694 static const int min_exponent10 = 0;
695 static const int max_exponent = 0;
696 static const int max_exponent10 = 0;
698 static const bool has_infinity = false;
699 static const bool has_quiet_NaN = false;
700 static const bool has_signaling_NaN = false;
701 static const float_denorm_style has_denorm = denorm_absent;
702 static const bool has_denorm_loss = false;
704 static int infinity() throw()
705 { return static_cast<int>(0); }
706 static int quiet_NaN() throw()
707 { return static_cast<int>(0); }
708 static int signaling_NaN() throw()
709 { return static_cast<int>(0); }
710 static int denorm_min() throw()
711 { return static_cast<int>(0); }
713 static const bool is_iec559 = false;
714 static const bool is_bounded = true;
715 static const bool is_modulo = true;
717 static const bool traps = __glibcxx_integral_traps;
718 static const bool tinyness_before = false;
719 static const float_round_style round_style = round_toward_zero;
722 /// numeric_limits<unsigned int> specialization.
724 struct numeric_limits<unsigned int>
726 static const bool is_specialized = true;
728 static unsigned int min() throw()
730 static unsigned int max() throw()
731 { return __INT_MAX__ * 2U + 1; }
733 static const int digits = __glibcxx_digits (unsigned int);
734 static const int digits10 = __glibcxx_digits10 (unsigned int);
735 static const bool is_signed = false;
736 static const bool is_integer = true;
737 static const bool is_exact = true;
738 static const int radix = 2;
739 static unsigned int epsilon() throw()
741 static unsigned int round_error() throw()
744 static const int min_exponent = 0;
745 static const int min_exponent10 = 0;
746 static const int max_exponent = 0;
747 static const int max_exponent10 = 0;
749 static const bool has_infinity = false;
750 static const bool has_quiet_NaN = false;
751 static const bool has_signaling_NaN = false;
752 static const float_denorm_style has_denorm = denorm_absent;
753 static const bool has_denorm_loss = false;
755 static unsigned int infinity() throw()
756 { return static_cast<unsigned int>(0); }
757 static unsigned int quiet_NaN() throw()
758 { return static_cast<unsigned int>(0); }
759 static unsigned int signaling_NaN() throw()
760 { return static_cast<unsigned int>(0); }
761 static unsigned int denorm_min() throw()
762 { return static_cast<unsigned int>(0); }
764 static const bool is_iec559 = false;
765 static const bool is_bounded = true;
766 static const bool is_modulo = true;
768 static const bool traps = __glibcxx_integral_traps;
769 static const bool tinyness_before = false;
770 static const float_round_style round_style = round_toward_zero;
773 /// numeric_limits<long> specialization.
775 struct numeric_limits<long>
777 static const bool is_specialized = true;
779 static long min() throw()
780 { return -__LONG_MAX__ - 1; }
781 static long max() throw()
782 { return __LONG_MAX__; }
784 static const int digits = __glibcxx_digits (long);
785 static const int digits10 = __glibcxx_digits10 (long);
786 static const bool is_signed = true;
787 static const bool is_integer = true;
788 static const bool is_exact = true;
789 static const int radix = 2;
790 static long epsilon() throw()
792 static long round_error() throw()
795 static const int min_exponent = 0;
796 static const int min_exponent10 = 0;
797 static const int max_exponent = 0;
798 static const int max_exponent10 = 0;
800 static const bool has_infinity = false;
801 static const bool has_quiet_NaN = false;
802 static const bool has_signaling_NaN = false;
803 static const float_denorm_style has_denorm = denorm_absent;
804 static const bool has_denorm_loss = false;
806 static long infinity() throw()
807 { return static_cast<long>(0); }
808 static long quiet_NaN() throw()
809 { return static_cast<long>(0); }
810 static long signaling_NaN() throw()
811 { return static_cast<long>(0); }
812 static long denorm_min() throw()
813 { return static_cast<long>(0); }
815 static const bool is_iec559 = false;
816 static const bool is_bounded = true;
817 static const bool is_modulo = true;
819 static const bool traps = __glibcxx_integral_traps;
820 static const bool tinyness_before = false;
821 static const float_round_style round_style = round_toward_zero;
824 /// numeric_limits<unsigned long> specialization.
826 struct numeric_limits<unsigned long>
828 static const bool is_specialized = true;
830 static unsigned long min() throw()
832 static unsigned long max() throw()
833 { return __LONG_MAX__ * 2UL + 1; }
835 static const int digits = __glibcxx_digits (unsigned long);
836 static const int digits10 = __glibcxx_digits10 (unsigned long);
837 static const bool is_signed = false;
838 static const bool is_integer = true;
839 static const bool is_exact = true;
840 static const int radix = 2;
841 static unsigned long epsilon() throw()
843 static unsigned long round_error() throw()
846 static const int min_exponent = 0;
847 static const int min_exponent10 = 0;
848 static const int max_exponent = 0;
849 static const int max_exponent10 = 0;
851 static const bool has_infinity = false;
852 static const bool has_quiet_NaN = false;
853 static const bool has_signaling_NaN = false;
854 static const float_denorm_style has_denorm = denorm_absent;
855 static const bool has_denorm_loss = false;
857 static unsigned long infinity() throw()
858 { return static_cast<unsigned long>(0); }
859 static unsigned long quiet_NaN() throw()
860 { return static_cast<unsigned long>(0); }
861 static unsigned long signaling_NaN() throw()
862 { return static_cast<unsigned long>(0); }
863 static unsigned long denorm_min() throw()
864 { return static_cast<unsigned long>(0); }
866 static const bool is_iec559 = false;
867 static const bool is_bounded = true;
868 static const bool is_modulo = true;
870 static const bool traps = __glibcxx_integral_traps;
871 static const bool tinyness_before = false;
872 static const float_round_style round_style = round_toward_zero;
875 /// numeric_limits<long long> specialization.
877 struct numeric_limits<long long>
879 static const bool is_specialized = true;
881 static long long min() throw()
882 { return -__LONG_LONG_MAX__ - 1; }
883 static long long max() throw()
884 { return __LONG_LONG_MAX__; }
886 static const int digits = __glibcxx_digits (long long);
887 static const int digits10 = __glibcxx_digits10 (long long);
888 static const bool is_signed = true;
889 static const bool is_integer = true;
890 static const bool is_exact = true;
891 static const int radix = 2;
892 static long long epsilon() throw()
894 static long long round_error() throw()
897 static const int min_exponent = 0;
898 static const int min_exponent10 = 0;
899 static const int max_exponent = 0;
900 static const int max_exponent10 = 0;
902 static const bool has_infinity = false;
903 static const bool has_quiet_NaN = false;
904 static const bool has_signaling_NaN = false;
905 static const float_denorm_style has_denorm = denorm_absent;
906 static const bool has_denorm_loss = false;
908 static long long infinity() throw()
909 { return static_cast<long long>(0); }
910 static long long quiet_NaN() throw()
911 { return static_cast<long long>(0); }
912 static long long signaling_NaN() throw()
913 { return static_cast<long long>(0); }
914 static long long denorm_min() throw()
915 { return static_cast<long long>(0); }
917 static const bool is_iec559 = false;
918 static const bool is_bounded = true;
919 static const bool is_modulo = true;
921 static const bool traps = __glibcxx_integral_traps;
922 static const bool tinyness_before = false;
923 static const float_round_style round_style = round_toward_zero;
926 /// numeric_limits<unsigned long long> specialization.
928 struct numeric_limits<unsigned long long>
930 static const bool is_specialized = true;
932 static unsigned long long min() throw()
934 static unsigned long long max() throw()
935 { return __LONG_LONG_MAX__ * 2ULL + 1; }
937 static const int digits = __glibcxx_digits (unsigned long long);
938 static const int digits10 = __glibcxx_digits10 (unsigned long long);
939 static const bool is_signed = false;
940 static const bool is_integer = true;
941 static const bool is_exact = true;
942 static const int radix = 2;
943 static unsigned long long epsilon() throw()
945 static unsigned long long round_error() throw()
948 static const int min_exponent = 0;
949 static const int min_exponent10 = 0;
950 static const int max_exponent = 0;
951 static const int max_exponent10 = 0;
953 static const bool has_infinity = false;
954 static const bool has_quiet_NaN = false;
955 static const bool has_signaling_NaN = false;
956 static const float_denorm_style has_denorm = denorm_absent;
957 static const bool has_denorm_loss = false;
959 static unsigned long long infinity() throw()
960 { return static_cast<unsigned long long>(0); }
961 static unsigned long long quiet_NaN() throw()
962 { return static_cast<unsigned long long>(0); }
963 static unsigned long long signaling_NaN() throw()
964 { return static_cast<unsigned long long>(0); }
965 static unsigned long long denorm_min() throw()
966 { return static_cast<unsigned long long>(0); }
968 static const bool is_iec559 = false;
969 static const bool is_bounded = true;
970 static const bool is_modulo = true;
972 static const bool traps = __glibcxx_integral_traps;
973 static const bool tinyness_before = false;
974 static const float_round_style round_style = round_toward_zero;
977 /// numeric_limits<float> specialization.
979 struct numeric_limits<float>
981 static const bool is_specialized = true;
983 static float min() throw()
984 { return __FLT_MIN__; }
985 static float max() throw()
986 { return __FLT_MAX__; }
988 static const int digits = __FLT_MANT_DIG__;
989 static const int digits10 = __FLT_DIG__;
990 static const bool is_signed = true;
991 static const bool is_integer = false;
992 static const bool is_exact = false;
993 static const int radix = __FLT_RADIX__;
994 static float epsilon() throw()
995 { return __FLT_EPSILON__; }
996 static float round_error() throw()
999 static const int min_exponent = __FLT_MIN_EXP__;
1000 static const int min_exponent10 = __FLT_MIN_10_EXP__;
1001 static const int max_exponent = __FLT_MAX_EXP__;
1002 static const int max_exponent10 = __FLT_MAX_10_EXP__;
1004 static const bool has_infinity = __FLT_HAS_INFINITY__;
1005 static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
1006 static const bool has_signaling_NaN = has_quiet_NaN;
1007 static const float_denorm_style has_denorm
1008 = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
1009 static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
1011 static float infinity() throw()
1012 { return __builtin_huge_valf (); }
1013 static float quiet_NaN() throw()
1014 { return __builtin_nanf (""); }
1015 static float signaling_NaN() throw()
1016 { return __builtin_nansf (""); }
1017 static float denorm_min() throw()
1018 { return __FLT_DENORM_MIN__; }
1020 static const bool is_iec559
1021 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1022 static const bool is_bounded = true;
1023 static const bool is_modulo = false;
1025 static const bool traps = __glibcxx_float_traps;
1026 static const bool tinyness_before = __glibcxx_float_tinyness_before;
1027 static const float_round_style round_style = round_to_nearest;
1030 #undef __glibcxx_float_has_denorm_loss
1031 #undef __glibcxx_float_traps
1032 #undef __glibcxx_float_tinyness_before
1034 /// numeric_limits<double> specialization.
1036 struct numeric_limits<double>
1038 static const bool is_specialized = true;
1040 static double min() throw()
1041 { return __DBL_MIN__; }
1042 static double max() throw()
1043 { return __DBL_MAX__; }
1045 static const int digits = __DBL_MANT_DIG__;
1046 static const int digits10 = __DBL_DIG__;
1047 static const bool is_signed = true;
1048 static const bool is_integer = false;
1049 static const bool is_exact = false;
1050 static const int radix = __FLT_RADIX__;
1051 static double epsilon() throw()
1052 { return __DBL_EPSILON__; }
1053 static double round_error() throw()
1056 static const int min_exponent = __DBL_MIN_EXP__;
1057 static const int min_exponent10 = __DBL_MIN_10_EXP__;
1058 static const int max_exponent = __DBL_MAX_EXP__;
1059 static const int max_exponent10 = __DBL_MAX_10_EXP__;
1061 static const bool has_infinity = __DBL_HAS_INFINITY__;
1062 static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
1063 static const bool has_signaling_NaN = has_quiet_NaN;
1064 static const float_denorm_style has_denorm
1065 = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1066 static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
1068 static double infinity() throw()
1069 { return __builtin_huge_val(); }
1070 static double quiet_NaN() throw()
1071 { return __builtin_nan (""); }
1072 static double signaling_NaN() throw()
1073 { return __builtin_nans (""); }
1074 static double denorm_min() throw()
1075 { return __DBL_DENORM_MIN__; }
1077 static const bool is_iec559
1078 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1079 static const bool is_bounded = true;
1080 static const bool is_modulo = false;
1082 static const bool traps = __glibcxx_double_traps;
1083 static const bool tinyness_before = __glibcxx_double_tinyness_before;
1084 static const float_round_style round_style = round_to_nearest;
1087 #undef __glibcxx_double_has_denorm_loss
1088 #undef __glibcxx_double_traps
1089 #undef __glibcxx_double_tinyness_before
1091 /// numeric_limits<long double> specialization.
1093 struct numeric_limits<long double>
1095 static const bool is_specialized = true;
1097 static long double min() throw()
1098 { return __LDBL_MIN__; }
1099 static long double max() throw()
1100 { return __LDBL_MAX__; }
1102 static const int digits = __LDBL_MANT_DIG__;
1103 static const int digits10 = __LDBL_DIG__;
1104 static const bool is_signed = true;
1105 static const bool is_integer = false;
1106 static const bool is_exact = false;
1107 static const int radix = __FLT_RADIX__;
1108 static long double epsilon() throw()
1109 { return __LDBL_EPSILON__; }
1110 static long double round_error() throw()
1113 static const int min_exponent = __LDBL_MIN_EXP__;
1114 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
1115 static const int max_exponent = __LDBL_MAX_EXP__;
1116 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
1118 static const bool has_infinity = __LDBL_HAS_INFINITY__;
1119 static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
1120 static const bool has_signaling_NaN = has_quiet_NaN;
1121 static const float_denorm_style has_denorm
1122 = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1123 static const bool has_denorm_loss
1124 = __glibcxx_long_double_has_denorm_loss;
1126 static long double infinity() throw()
1127 { return __builtin_huge_vall (); }
1128 static long double quiet_NaN() throw()
1129 { return __builtin_nanl (""); }
1130 static long double signaling_NaN() throw()
1131 { return __builtin_nansl (""); }
1132 static long double denorm_min() throw()
1133 { return __LDBL_DENORM_MIN__; }
1135 static const bool is_iec559
1136 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1137 static const bool is_bounded = true;
1138 static const bool is_modulo = false;
1140 static const bool traps = __glibcxx_long_double_traps;
1141 static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
1142 static const float_round_style round_style = round_to_nearest;
1145 #undef __glibcxx_long_double_has_denorm_loss
1146 #undef __glibcxx_long_double_traps
1147 #undef __glibcxx_long_double_tinyness_before
1149 _GLIBCXX_END_NAMESPACE
1151 #undef __glibcxx_signed
1152 #undef __glibcxx_min
1153 #undef __glibcxx_max
1154 #undef __glibcxx_digits
1155 #undef __glibcxx_digits10
1157 #endif // _GLIBCXX_NUMERIC_LIMITS