1 // The template and inlines for the numeric_limits classes. -*- C++ -*-
3 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005
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 along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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++ undertstands (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 intrinsicly supports modulo integral types. The only remaining
83 // integral exceptional values is division by zero. Only targets that do not
84 // signal division by zero in some "hard to ignore" way should use false.
85 #ifndef __glibcxx_integral_traps
86 # define __glibcxx_integral_traps true
92 // Default values. Should be overriden 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 overriden 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 overriden 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) - 1)) << 1) : (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 seperate class for purposes of efficiency; you
190 * should only access these members as part of an instantiation
191 * of the std::numeric_limits class.
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.
209 * Is this supposed to be "if the type is integral"?
212 static const bool is_integer = false;
213 /** True if the type uses an exact representation. "All integer types are
214 exact, but not all exact types are integer. For example, rational and
215 fixed-exponent representations are exact but not integer."
217 static const bool is_exact = false;
218 /** For integer types, specifies the base of the representation. For
219 floating types, specifies the base of the exponent representation. */
220 static const int radix = 0;
222 /** The minimum negative integer such that @c radix raised to the power of
223 (one less than that integer) is a normalized floating point number. */
224 static const int min_exponent = 0;
225 /** The minimum negative integer such that 10 raised to that power is in
226 the range of normalized floating point numbers. */
227 static const int min_exponent10 = 0;
228 /** The maximum positive integer such that @c radix raised to the power of
229 (one less than that integer) is a representable finite floating point
231 static const int max_exponent = 0;
232 /** The maximum positive integer such that 10 raised to that power is in
233 the range of representable finite floating point numbers. */
234 static const int max_exponent10 = 0;
236 /** True if the type has a representation for positive infinity. */
237 static const bool has_infinity = false;
238 /** True if the type has a representation for a quiet (non-signaling)
240 static const bool has_quiet_NaN = false;
241 /** True if the type has a representation for a signaling
243 static const bool has_signaling_NaN = false;
244 /** See std::float_denorm_style for more information. */
245 static const float_denorm_style has_denorm = denorm_absent;
246 /** "True if loss of accuracy is detected as a denormalization loss,
247 rather than as an inexact result." [18.2.1.2]/42 */
248 static const bool has_denorm_loss = false;
250 /** True if-and-only-if the type adheres to the IEC 559 standard, also
251 known as IEEE 754. (Only makes sense for floating point types.) */
252 static const bool is_iec559 = false;
253 /** "True if the set of values representable by the type is finite. All
254 built-in types are bounded, this member would be false for arbitrary
255 precision types." [18.2.1.2]/54 */
256 static const bool is_bounded = false;
257 /** True if the type is @e modulo, that is, if it is possible to add two
258 positive numbers and have a result that wraps around to a third number
259 that is less. Typically false for floating types, true for unsigned
260 integers, and true for signed integers. */
261 static const bool is_modulo = false;
263 /** True if trapping is implemented for this type. */
264 static const bool traps = false;
265 /** True if tinyness is detected before rounding. (see IEC 559) */
266 static const bool tinyness_before = false;
267 /** See std::float_round_style for more information. This is only
268 meaningful for floating types; integer types will all be
269 round_toward_zero. */
270 static const float_round_style round_style = round_toward_zero;
274 * @brief Properties of fundamental types.
276 * This class allows a program to obtain information about the
277 * representation of a fundamental type on a given platform. For
278 * non-fundamental types, the functions will return 0 and the data
279 * members will all be @c false.
282 * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
283 * noted, but not incorporated in this documented (yet).
286 template<typename _Tp>
287 struct numeric_limits : public __numeric_limits_base
289 /** The minimum finite value, or for floating types with
290 denormalization, the minimum positive normalized value. */
291 static _Tp min() throw() { return static_cast<_Tp>(0); }
292 /** The maximum finite value. */
293 static _Tp max() throw() { return static_cast<_Tp>(0); }
294 /** The @e machine @e epsilon: the difference between 1 and the least
295 value greater than 1 that is representable. */
296 static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
297 /** The maximum rounding error measurement (see LIA-1). */
298 static _Tp round_error() throw() { return static_cast<_Tp>(0); }
299 /** The representation of positive infinity, if @c has_infinity. */
300 static _Tp infinity() throw() { return static_cast<_Tp>(0); }
301 /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */
302 static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
303 /** The representation of a signaling "Not a Number," if
304 @c has_signaling_NaN. */
305 static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
306 /** The minimum positive denormalized value. For types where
307 @c has_denorm is false, this is the minimum positive normalized
309 static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
312 // Now there follow 15 explicit specializations. Yes, 15. Make sure
313 // you get the count right.
315 /// numeric_limits<bool> specialization.
317 struct numeric_limits<bool>
319 static const bool is_specialized = true;
321 static bool min() throw()
323 static bool max() throw()
326 static const int digits = 1;
327 static const int digits10 = 0;
328 static const bool is_signed = false;
329 static const bool is_integer = true;
330 static const bool is_exact = true;
331 static const int radix = 2;
332 static bool epsilon() throw()
334 static bool round_error() throw()
337 static const int min_exponent = 0;
338 static const int min_exponent10 = 0;
339 static const int max_exponent = 0;
340 static const int max_exponent10 = 0;
342 static const bool has_infinity = false;
343 static const bool has_quiet_NaN = false;
344 static const bool has_signaling_NaN = false;
345 static const float_denorm_style has_denorm = denorm_absent;
346 static const bool has_denorm_loss = false;
348 static bool infinity() throw()
350 static bool quiet_NaN() throw()
352 static bool signaling_NaN() throw()
354 static bool denorm_min() throw()
357 static const bool is_iec559 = false;
358 static const bool is_bounded = true;
359 static const bool is_modulo = false;
361 // It is not clear what it means for a boolean type to trap.
362 // This is a DR on the LWG issue list. Here, I use integer
363 // promotion semantics.
364 static const bool traps = __glibcxx_integral_traps;
365 static const bool tinyness_before = false;
366 static const float_round_style round_style = round_toward_zero;
369 /// numeric_limits<char> specialization.
371 struct numeric_limits<char>
373 static const bool is_specialized = true;
375 static char min() throw()
376 { return __glibcxx_min(char); }
377 static char max() throw()
378 { return __glibcxx_max(char); }
380 static const int digits = __glibcxx_digits (char);
381 static const int digits10 = __glibcxx_digits10 (char);
382 static const bool is_signed = __glibcxx_signed (char);
383 static const bool is_integer = true;
384 static const bool is_exact = true;
385 static const int radix = 2;
386 static char epsilon() throw()
388 static char round_error() throw()
391 static const int min_exponent = 0;
392 static const int min_exponent10 = 0;
393 static const int max_exponent = 0;
394 static const int max_exponent10 = 0;
396 static const bool has_infinity = false;
397 static const bool has_quiet_NaN = false;
398 static const bool has_signaling_NaN = false;
399 static const float_denorm_style has_denorm = denorm_absent;
400 static const bool has_denorm_loss = false;
402 static char infinity() throw()
404 static char quiet_NaN() throw()
406 static char signaling_NaN() throw()
408 static char denorm_min() throw()
409 { return static_cast<char>(0); }
411 static const bool is_iec559 = false;
412 static const bool is_bounded = true;
413 static const bool is_modulo = true;
415 static const bool traps = __glibcxx_integral_traps;
416 static const bool tinyness_before = false;
417 static const float_round_style round_style = round_toward_zero;
420 /// numeric_limits<signed char> specialization.
422 struct numeric_limits<signed char>
424 static const bool is_specialized = true;
426 static signed char min() throw()
427 { return -__SCHAR_MAX__ - 1; }
428 static signed char max() throw()
429 { return __SCHAR_MAX__; }
431 static const int digits = __glibcxx_digits (signed char);
432 static const int digits10 = __glibcxx_digits10 (signed char);
433 static const bool is_signed = true;
434 static const bool is_integer = true;
435 static const bool is_exact = true;
436 static const int radix = 2;
437 static signed char epsilon() throw()
439 static signed char round_error() throw()
442 static const int min_exponent = 0;
443 static const int min_exponent10 = 0;
444 static const int max_exponent = 0;
445 static const int max_exponent10 = 0;
447 static const bool has_infinity = false;
448 static const bool has_quiet_NaN = false;
449 static const bool has_signaling_NaN = false;
450 static const float_denorm_style has_denorm = denorm_absent;
451 static const bool has_denorm_loss = false;
453 static signed char infinity() throw()
454 { return static_cast<signed char>(0); }
455 static signed char quiet_NaN() throw()
456 { return static_cast<signed char>(0); }
457 static signed char signaling_NaN() throw()
458 { return static_cast<signed char>(0); }
459 static signed char denorm_min() throw()
460 { return static_cast<signed char>(0); }
462 static const bool is_iec559 = false;
463 static const bool is_bounded = true;
464 static const bool is_modulo = true;
466 static const bool traps = __glibcxx_integral_traps;
467 static const bool tinyness_before = false;
468 static const float_round_style round_style = round_toward_zero;
471 /// numeric_limits<unsigned char> specialization.
473 struct numeric_limits<unsigned char>
475 static const bool is_specialized = true;
477 static unsigned char min() throw()
479 static unsigned char max() throw()
480 { return __SCHAR_MAX__ * 2U + 1; }
482 static const int digits = __glibcxx_digits (unsigned char);
483 static const int digits10 = __glibcxx_digits10 (unsigned char);
484 static const bool is_signed = false;
485 static const bool is_integer = true;
486 static const bool is_exact = true;
487 static const int radix = 2;
488 static unsigned char epsilon() throw()
490 static unsigned char round_error() throw()
493 static const int min_exponent = 0;
494 static const int min_exponent10 = 0;
495 static const int max_exponent = 0;
496 static const int max_exponent10 = 0;
498 static const bool has_infinity = false;
499 static const bool has_quiet_NaN = false;
500 static const bool has_signaling_NaN = false;
501 static const float_denorm_style has_denorm = denorm_absent;
502 static const bool has_denorm_loss = false;
504 static unsigned char infinity() throw()
505 { return static_cast<unsigned char>(0); }
506 static unsigned char quiet_NaN() throw()
507 { return static_cast<unsigned char>(0); }
508 static unsigned char signaling_NaN() throw()
509 { return static_cast<unsigned char>(0); }
510 static unsigned char denorm_min() throw()
511 { return static_cast<unsigned char>(0); }
513 static const bool is_iec559 = false;
514 static const bool is_bounded = true;
515 static const bool is_modulo = true;
517 static const bool traps = __glibcxx_integral_traps;
518 static const bool tinyness_before = false;
519 static const float_round_style round_style = round_toward_zero;
522 /// numeric_limits<wchar_t> specialization.
524 struct numeric_limits<wchar_t>
526 static const bool is_specialized = true;
528 static wchar_t min() throw()
529 { return __glibcxx_min (wchar_t); }
530 static wchar_t max() throw()
531 { return __glibcxx_max (wchar_t); }
533 static const int digits = __glibcxx_digits (wchar_t);
534 static const int digits10 = __glibcxx_digits10 (wchar_t);
535 static const bool is_signed = __glibcxx_signed (wchar_t);
536 static const bool is_integer = true;
537 static const bool is_exact = true;
538 static const int radix = 2;
539 static wchar_t epsilon() throw()
541 static wchar_t round_error() throw()
544 static const int min_exponent = 0;
545 static const int min_exponent10 = 0;
546 static const int max_exponent = 0;
547 static const int max_exponent10 = 0;
549 static const bool has_infinity = false;
550 static const bool has_quiet_NaN = false;
551 static const bool has_signaling_NaN = false;
552 static const float_denorm_style has_denorm = denorm_absent;
553 static const bool has_denorm_loss = false;
555 static wchar_t infinity() throw()
556 { return wchar_t(); }
557 static wchar_t quiet_NaN() throw()
558 { return wchar_t(); }
559 static wchar_t signaling_NaN() throw()
560 { return wchar_t(); }
561 static wchar_t denorm_min() throw()
562 { return wchar_t(); }
564 static const bool is_iec559 = false;
565 static const bool is_bounded = true;
566 static const bool is_modulo = true;
568 static const bool traps = __glibcxx_integral_traps;
569 static const bool tinyness_before = false;
570 static const float_round_style round_style = round_toward_zero;
573 /// numeric_limits<short> specialization.
575 struct numeric_limits<short>
577 static const bool is_specialized = true;
579 static short min() throw()
580 { return -__SHRT_MAX__ - 1; }
581 static short max() throw()
582 { return __SHRT_MAX__; }
584 static const int digits = __glibcxx_digits (short);
585 static const int digits10 = __glibcxx_digits10 (short);
586 static const bool is_signed = true;
587 static const bool is_integer = true;
588 static const bool is_exact = true;
589 static const int radix = 2;
590 static short epsilon() throw()
592 static short round_error() throw()
595 static const int min_exponent = 0;
596 static const int min_exponent10 = 0;
597 static const int max_exponent = 0;
598 static const int max_exponent10 = 0;
600 static const bool has_infinity = false;
601 static const bool has_quiet_NaN = false;
602 static const bool has_signaling_NaN = false;
603 static const float_denorm_style has_denorm = denorm_absent;
604 static const bool has_denorm_loss = false;
606 static short infinity() throw()
608 static short quiet_NaN() throw()
610 static short signaling_NaN() throw()
612 static short denorm_min() throw()
615 static const bool is_iec559 = false;
616 static const bool is_bounded = true;
617 static const bool is_modulo = true;
619 static const bool traps = __glibcxx_integral_traps;
620 static const bool tinyness_before = false;
621 static const float_round_style round_style = round_toward_zero;
624 /// numeric_limits<unsigned short> specialization.
626 struct numeric_limits<unsigned short>
628 static const bool is_specialized = true;
630 static unsigned short min() throw()
632 static unsigned short max() throw()
633 { return __SHRT_MAX__ * 2U + 1; }
635 static const int digits = __glibcxx_digits (unsigned short);
636 static const int digits10 = __glibcxx_digits10 (unsigned short);
637 static const bool is_signed = false;
638 static const bool is_integer = true;
639 static const bool is_exact = true;
640 static const int radix = 2;
641 static unsigned short epsilon() throw()
643 static unsigned short round_error() throw()
646 static const int min_exponent = 0;
647 static const int min_exponent10 = 0;
648 static const int max_exponent = 0;
649 static const int max_exponent10 = 0;
651 static const bool has_infinity = false;
652 static const bool has_quiet_NaN = false;
653 static const bool has_signaling_NaN = false;
654 static const float_denorm_style has_denorm = denorm_absent;
655 static const bool has_denorm_loss = false;
657 static unsigned short infinity() throw()
658 { return static_cast<unsigned short>(0); }
659 static unsigned short quiet_NaN() throw()
660 { return static_cast<unsigned short>(0); }
661 static unsigned short signaling_NaN() throw()
662 { return static_cast<unsigned short>(0); }
663 static unsigned short denorm_min() throw()
664 { return static_cast<unsigned short>(0); }
666 static const bool is_iec559 = false;
667 static const bool is_bounded = true;
668 static const bool is_modulo = true;
670 static const bool traps = __glibcxx_integral_traps;
671 static const bool tinyness_before = false;
672 static const float_round_style round_style = round_toward_zero;
675 /// numeric_limits<int> specialization.
677 struct numeric_limits<int>
679 static const bool is_specialized = true;
681 static int min() throw()
682 { return -__INT_MAX__ - 1; }
683 static int max() throw()
684 { return __INT_MAX__; }
686 static const int digits = __glibcxx_digits (int);
687 static const int digits10 = __glibcxx_digits10 (int);
688 static const bool is_signed = true;
689 static const bool is_integer = true;
690 static const bool is_exact = true;
691 static const int radix = 2;
692 static int epsilon() throw()
694 static int round_error() throw()
697 static const int min_exponent = 0;
698 static const int min_exponent10 = 0;
699 static const int max_exponent = 0;
700 static const int max_exponent10 = 0;
702 static const bool has_infinity = false;
703 static const bool has_quiet_NaN = false;
704 static const bool has_signaling_NaN = false;
705 static const float_denorm_style has_denorm = denorm_absent;
706 static const bool has_denorm_loss = false;
708 static int infinity() throw()
709 { return static_cast<int>(0); }
710 static int quiet_NaN() throw()
711 { return static_cast<int>(0); }
712 static int signaling_NaN() throw()
713 { return static_cast<int>(0); }
714 static int denorm_min() throw()
715 { return static_cast<int>(0); }
717 static const bool is_iec559 = false;
718 static const bool is_bounded = true;
719 static const bool is_modulo = true;
721 static const bool traps = __glibcxx_integral_traps;
722 static const bool tinyness_before = false;
723 static const float_round_style round_style = round_toward_zero;
726 /// numeric_limits<unsigned int> specialization.
728 struct numeric_limits<unsigned int>
730 static const bool is_specialized = true;
732 static unsigned int min() throw()
734 static unsigned int max() throw()
735 { return __INT_MAX__ * 2U + 1; }
737 static const int digits = __glibcxx_digits (unsigned int);
738 static const int digits10 = __glibcxx_digits10 (unsigned int);
739 static const bool is_signed = false;
740 static const bool is_integer = true;
741 static const bool is_exact = true;
742 static const int radix = 2;
743 static unsigned int epsilon() throw()
745 static unsigned int round_error() throw()
748 static const int min_exponent = 0;
749 static const int min_exponent10 = 0;
750 static const int max_exponent = 0;
751 static const int max_exponent10 = 0;
753 static const bool has_infinity = false;
754 static const bool has_quiet_NaN = false;
755 static const bool has_signaling_NaN = false;
756 static const float_denorm_style has_denorm = denorm_absent;
757 static const bool has_denorm_loss = false;
759 static unsigned int infinity() throw()
760 { return static_cast<unsigned int>(0); }
761 static unsigned int quiet_NaN() throw()
762 { return static_cast<unsigned int>(0); }
763 static unsigned int signaling_NaN() throw()
764 { return static_cast<unsigned int>(0); }
765 static unsigned int denorm_min() throw()
766 { return static_cast<unsigned int>(0); }
768 static const bool is_iec559 = false;
769 static const bool is_bounded = true;
770 static const bool is_modulo = true;
772 static const bool traps = __glibcxx_integral_traps;
773 static const bool tinyness_before = false;
774 static const float_round_style round_style = round_toward_zero;
777 /// numeric_limits<long> specialization.
779 struct numeric_limits<long>
781 static const bool is_specialized = true;
783 static long min() throw()
784 { return -__LONG_MAX__ - 1; }
785 static long max() throw()
786 { return __LONG_MAX__; }
788 static const int digits = __glibcxx_digits (long);
789 static const int digits10 = __glibcxx_digits10 (long);
790 static const bool is_signed = true;
791 static const bool is_integer = true;
792 static const bool is_exact = true;
793 static const int radix = 2;
794 static long epsilon() throw()
796 static long round_error() throw()
799 static const int min_exponent = 0;
800 static const int min_exponent10 = 0;
801 static const int max_exponent = 0;
802 static const int max_exponent10 = 0;
804 static const bool has_infinity = false;
805 static const bool has_quiet_NaN = false;
806 static const bool has_signaling_NaN = false;
807 static const float_denorm_style has_denorm = denorm_absent;
808 static const bool has_denorm_loss = false;
810 static long infinity() throw()
811 { return static_cast<long>(0); }
812 static long quiet_NaN() throw()
813 { return static_cast<long>(0); }
814 static long signaling_NaN() throw()
815 { return static_cast<long>(0); }
816 static long denorm_min() throw()
817 { return static_cast<long>(0); }
819 static const bool is_iec559 = false;
820 static const bool is_bounded = true;
821 static const bool is_modulo = true;
823 static const bool traps = __glibcxx_integral_traps;
824 static const bool tinyness_before = false;
825 static const float_round_style round_style = round_toward_zero;
828 /// numeric_limits<unsigned long> specialization.
830 struct numeric_limits<unsigned long>
832 static const bool is_specialized = true;
834 static unsigned long min() throw()
836 static unsigned long max() throw()
837 { return __LONG_MAX__ * 2UL + 1; }
839 static const int digits = __glibcxx_digits (unsigned long);
840 static const int digits10 = __glibcxx_digits10 (unsigned long);
841 static const bool is_signed = false;
842 static const bool is_integer = true;
843 static const bool is_exact = true;
844 static const int radix = 2;
845 static unsigned long epsilon() throw()
847 static unsigned long round_error() throw()
850 static const int min_exponent = 0;
851 static const int min_exponent10 = 0;
852 static const int max_exponent = 0;
853 static const int max_exponent10 = 0;
855 static const bool has_infinity = false;
856 static const bool has_quiet_NaN = false;
857 static const bool has_signaling_NaN = false;
858 static const float_denorm_style has_denorm = denorm_absent;
859 static const bool has_denorm_loss = false;
861 static unsigned long infinity() throw()
862 { return static_cast<unsigned long>(0); }
863 static unsigned long quiet_NaN() throw()
864 { return static_cast<unsigned long>(0); }
865 static unsigned long signaling_NaN() throw()
866 { return static_cast<unsigned long>(0); }
867 static unsigned long denorm_min() throw()
868 { return static_cast<unsigned long>(0); }
870 static const bool is_iec559 = false;
871 static const bool is_bounded = true;
872 static const bool is_modulo = true;
874 static const bool traps = __glibcxx_integral_traps;
875 static const bool tinyness_before = false;
876 static const float_round_style round_style = round_toward_zero;
879 /// numeric_limits<long long> specialization.
881 struct numeric_limits<long long>
883 static const bool is_specialized = true;
885 static long long min() throw()
886 { return -__LONG_LONG_MAX__ - 1; }
887 static long long max() throw()
888 { return __LONG_LONG_MAX__; }
890 static const int digits = __glibcxx_digits (long long);
891 static const int digits10 = __glibcxx_digits10 (long long);
892 static const bool is_signed = true;
893 static const bool is_integer = true;
894 static const bool is_exact = true;
895 static const int radix = 2;
896 static long long epsilon() throw()
898 static long long round_error() throw()
901 static const int min_exponent = 0;
902 static const int min_exponent10 = 0;
903 static const int max_exponent = 0;
904 static const int max_exponent10 = 0;
906 static const bool has_infinity = false;
907 static const bool has_quiet_NaN = false;
908 static const bool has_signaling_NaN = false;
909 static const float_denorm_style has_denorm = denorm_absent;
910 static const bool has_denorm_loss = false;
912 static long long infinity() throw()
913 { return static_cast<long long>(0); }
914 static long long quiet_NaN() throw()
915 { return static_cast<long long>(0); }
916 static long long signaling_NaN() throw()
917 { return static_cast<long long>(0); }
918 static long long denorm_min() throw()
919 { return static_cast<long long>(0); }
921 static const bool is_iec559 = false;
922 static const bool is_bounded = true;
923 static const bool is_modulo = true;
925 static const bool traps = __glibcxx_integral_traps;
926 static const bool tinyness_before = false;
927 static const float_round_style round_style = round_toward_zero;
930 /// numeric_limits<unsigned long long> specialization.
932 struct numeric_limits<unsigned long long>
934 static const bool is_specialized = true;
936 static unsigned long long min() throw()
938 static unsigned long long max() throw()
939 { return __LONG_LONG_MAX__ * 2ULL + 1; }
941 static const int digits = __glibcxx_digits (unsigned long long);
942 static const int digits10 = __glibcxx_digits10 (unsigned long long);
943 static const bool is_signed = false;
944 static const bool is_integer = true;
945 static const bool is_exact = true;
946 static const int radix = 2;
947 static unsigned long long epsilon() throw()
949 static unsigned long long round_error() throw()
952 static const int min_exponent = 0;
953 static const int min_exponent10 = 0;
954 static const int max_exponent = 0;
955 static const int max_exponent10 = 0;
957 static const bool has_infinity = false;
958 static const bool has_quiet_NaN = false;
959 static const bool has_signaling_NaN = false;
960 static const float_denorm_style has_denorm = denorm_absent;
961 static const bool has_denorm_loss = false;
963 static unsigned long long infinity() throw()
964 { return static_cast<unsigned long long>(0); }
965 static unsigned long long quiet_NaN() throw()
966 { return static_cast<unsigned long long>(0); }
967 static unsigned long long signaling_NaN() throw()
968 { return static_cast<unsigned long long>(0); }
969 static unsigned long long denorm_min() throw()
970 { return static_cast<unsigned long long>(0); }
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 = round_toward_zero;
981 /// numeric_limits<float> specialization.
983 struct numeric_limits<float>
985 static const bool is_specialized = true;
987 static float min() throw()
988 { return __FLT_MIN__; }
989 static float max() throw()
990 { return __FLT_MAX__; }
992 static const int digits = __FLT_MANT_DIG__;
993 static const int digits10 = __FLT_DIG__;
994 static const bool is_signed = true;
995 static const bool is_integer = false;
996 static const bool is_exact = false;
997 static const int radix = __FLT_RADIX__;
998 static float epsilon() throw()
999 { return __FLT_EPSILON__; }
1000 static float round_error() throw()
1003 static const int min_exponent = __FLT_MIN_EXP__;
1004 static const int min_exponent10 = __FLT_MIN_10_EXP__;
1005 static const int max_exponent = __FLT_MAX_EXP__;
1006 static const int max_exponent10 = __FLT_MAX_10_EXP__;
1008 static const bool has_infinity = __FLT_HAS_INFINITY__;
1009 static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
1010 static const bool has_signaling_NaN = has_quiet_NaN;
1011 static const float_denorm_style has_denorm
1012 = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
1013 static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
1015 static float infinity() throw()
1016 { return __builtin_huge_valf (); }
1017 static float quiet_NaN() throw()
1018 { return __builtin_nanf (""); }
1019 static float signaling_NaN() throw()
1020 { return __builtin_nansf (""); }
1021 static float denorm_min() throw()
1022 { return __FLT_DENORM_MIN__; }
1024 static const bool is_iec559
1025 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1026 static const bool is_bounded = true;
1027 static const bool is_modulo = false;
1029 static const bool traps = __glibcxx_float_traps;
1030 static const bool tinyness_before = __glibcxx_float_tinyness_before;
1031 static const float_round_style round_style = round_to_nearest;
1034 #undef __glibcxx_float_has_denorm_loss
1035 #undef __glibcxx_float_traps
1036 #undef __glibcxx_float_tinyness_before
1038 /// numeric_limits<double> specialization.
1040 struct numeric_limits<double>
1042 static const bool is_specialized = true;
1044 static double min() throw()
1045 { return __DBL_MIN__; }
1046 static double max() throw()
1047 { return __DBL_MAX__; }
1049 static const int digits = __DBL_MANT_DIG__;
1050 static const int digits10 = __DBL_DIG__;
1051 static const bool is_signed = true;
1052 static const bool is_integer = false;
1053 static const bool is_exact = false;
1054 static const int radix = __FLT_RADIX__;
1055 static double epsilon() throw()
1056 { return __DBL_EPSILON__; }
1057 static double round_error() throw()
1060 static const int min_exponent = __DBL_MIN_EXP__;
1061 static const int min_exponent10 = __DBL_MIN_10_EXP__;
1062 static const int max_exponent = __DBL_MAX_EXP__;
1063 static const int max_exponent10 = __DBL_MAX_10_EXP__;
1065 static const bool has_infinity = __DBL_HAS_INFINITY__;
1066 static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
1067 static const bool has_signaling_NaN = has_quiet_NaN;
1068 static const float_denorm_style has_denorm
1069 = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1070 static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
1072 static double infinity() throw()
1073 { return __builtin_huge_val(); }
1074 static double quiet_NaN() throw()
1075 { return __builtin_nan (""); }
1076 static double signaling_NaN() throw()
1077 { return __builtin_nans (""); }
1078 static double denorm_min() throw()
1079 { return __DBL_DENORM_MIN__; }
1081 static const bool is_iec559
1082 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1083 static const bool is_bounded = true;
1084 static const bool is_modulo = false;
1086 static const bool traps = __glibcxx_double_traps;
1087 static const bool tinyness_before = __glibcxx_double_tinyness_before;
1088 static const float_round_style round_style = round_to_nearest;
1091 #undef __glibcxx_double_has_denorm_loss
1092 #undef __glibcxx_double_traps
1093 #undef __glibcxx_double_tinyness_before
1095 /// numeric_limits<long double> specialization.
1097 struct numeric_limits<long double>
1099 static const bool is_specialized = true;
1101 static long double min() throw()
1102 { return __LDBL_MIN__; }
1103 static long double max() throw()
1104 { return __LDBL_MAX__; }
1106 static const int digits = __LDBL_MANT_DIG__;
1107 static const int digits10 = __LDBL_DIG__;
1108 static const bool is_signed = true;
1109 static const bool is_integer = false;
1110 static const bool is_exact = false;
1111 static const int radix = __FLT_RADIX__;
1112 static long double epsilon() throw()
1113 { return __LDBL_EPSILON__; }
1114 static long double round_error() throw()
1117 static const int min_exponent = __LDBL_MIN_EXP__;
1118 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
1119 static const int max_exponent = __LDBL_MAX_EXP__;
1120 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
1122 static const bool has_infinity = __LDBL_HAS_INFINITY__;
1123 static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
1124 static const bool has_signaling_NaN = has_quiet_NaN;
1125 static const float_denorm_style has_denorm
1126 = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1127 static const bool has_denorm_loss
1128 = __glibcxx_long_double_has_denorm_loss;
1130 static long double infinity() throw()
1131 { return __builtin_huge_vall (); }
1132 static long double quiet_NaN() throw()
1133 { return __builtin_nanl (""); }
1134 static long double signaling_NaN() throw()
1135 { return __builtin_nansl (""); }
1136 static long double denorm_min() throw()
1137 { return __LDBL_DENORM_MIN__; }
1139 static const bool is_iec559
1140 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1141 static const bool is_bounded = true;
1142 static const bool is_modulo = false;
1144 static const bool traps = __glibcxx_long_double_traps;
1145 static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
1146 static const float_round_style round_style = round_to_nearest;
1149 #undef __glibcxx_long_double_has_denorm_loss
1150 #undef __glibcxx_long_double_traps
1151 #undef __glibcxx_long_double_tinyness_before
1153 _GLIBCXX_END_NAMESPACE
1155 #undef __glibcxx_signed
1156 #undef __glibcxx_min
1157 #undef __glibcxx_max
1158 #undef __glibcxx_digits
1159 #undef __glibcxx_digits10
1161 #endif // _GLIBCXX_NUMERIC_LIMITS