2004-11-23 Benjamin Kosnik <bkoz@redhat.com>
[official-gcc.git] / libstdc++-v3 / include / std / std_limits.h
blob9bc99e1a4e9c7dd4418908fa1563baf602790862
1 // The template and inlines for the -*- C++ -*- numeric_limits classes.
3 // Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 /** @file limits
31 * This is a Standard C++ Library header.
34 // Note: this is not a conforming implementation.
35 // Written by Gabriel Dos Reis <gdr@codesourcery.com>
38 // ISO 14882:1998
39 // 18.2.1
42 #ifndef _GLIBCXX_NUMERIC_LIMITS
43 #define _GLIBCXX_NUMERIC_LIMITS 1
45 #pragma GCC system_header
47 #include <bits/c++config.h>
50 // The numeric_limits<> traits document implementation-defined aspects
51 // of fundamental arithmetic data types (integers and floating points).
52 // From Standard C++ point of view, there are 13 such types:
53 // * integers
54 // bool (1)
55 // char, signed char, unsigned char (3)
56 // short, unsigned short (2)
57 // int, unsigned (2)
58 // long, unsigned long (2)
60 // * floating points
61 // float (1)
62 // double (1)
63 // long double (1)
65 // GNU C++ undertstands (where supported by the host C-library)
66 // * integer
67 // long long, unsigned long long (2)
69 // which brings us to 15 fundamental arithmetic data types in GNU C++.
72 // Since a numeric_limits<> is a bit tricky to get right, we rely on
73 // an interface composed of macros which should be defined in config/os
74 // or config/cpu when they differ from the generic (read arbitrary)
75 // definitions given here.
78 // These values can be overridden in the target configuration file.
79 // The default values are appropriate for many 32-bit targets.
81 // GCC only intrinsicly supports modulo integral types. The only remaining
82 // integral exceptional values is division by zero. Only targets that do not
83 // signal division by zero in some "hard to ignore" way should use false.
84 #ifndef __glibcxx_integral_traps
85 # define __glibcxx_integral_traps true
86 #endif
88 // float
91 // Default values. Should be overriden in configuration files if necessary.
93 #ifndef __glibcxx_float_has_denorm_loss
94 # define __glibcxx_float_has_denorm_loss false
95 #endif
96 #ifndef __glibcxx_float_traps
97 # define __glibcxx_float_traps false
98 #endif
99 #ifndef __glibcxx_float_tinyness_before
100 # define __glibcxx_float_tinyness_before false
101 #endif
103 // double
105 // Default values. Should be overriden in configuration files if necessary.
107 #ifndef __glibcxx_double_has_denorm_loss
108 # define __glibcxx_double_has_denorm_loss false
109 #endif
110 #ifndef __glibcxx_double_traps
111 # define __glibcxx_double_traps false
112 #endif
113 #ifndef __glibcxx_double_tinyness_before
114 # define __glibcxx_double_tinyness_before false
115 #endif
117 // long double
119 // Default values. Should be overriden in configuration files if necessary.
121 #ifndef __glibcxx_long_double_has_denorm_loss
122 # define __glibcxx_long_double_has_denorm_loss false
123 #endif
124 #ifndef __glibcxx_long_double_traps
125 # define __glibcxx_long_double_traps false
126 #endif
127 #ifndef __glibcxx_long_double_tinyness_before
128 # define __glibcxx_long_double_tinyness_before false
129 #endif
131 // You should not need to define any macros below this point.
133 #define __glibcxx_signed(T) ((T)(-1) < 0)
135 #define __glibcxx_min(T) \
136 (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
138 #define __glibcxx_max(T) \
139 (__glibcxx_signed (T) ? ((T)1 << __glibcxx_digits (T)) - 1 : ~(T)0)
141 #define __glibcxx_digits(T) \
142 (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
144 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
145 #define __glibcxx_digits10(T) \
146 (__glibcxx_digits (T) * 643 / 2136)
149 namespace std
152 * @brief Describes the rounding style for floating-point types.
154 * This is used in the std::numeric_limits class.
156 enum float_round_style
158 round_indeterminate = -1, ///< Self-explanatory.
159 round_toward_zero = 0, ///< Self-explanatory.
160 round_to_nearest = 1, ///< To the nearest representable value.
161 round_toward_infinity = 2, ///< Self-explanatory.
162 round_toward_neg_infinity = 3 ///< Self-explanatory.
166 * @brief Describes the denormalization for floating-point types.
168 * These values represent the presence or absence of a variable number
169 * of exponent bits. This type is used in the std::numeric_limits class.
171 enum float_denorm_style
173 /// Indeterminate at compile time whether denormalized values are allowed.
174 denorm_indeterminate = -1,
175 /// The type does not allow denormalized values.
176 denorm_absent = 0,
177 /// The type allows denormalized values.
178 denorm_present = 1
182 * @brief Part of std::numeric_limits.
184 * The @c static @c const members are usable as integral constant
185 * expressions.
187 * @note This is a seperate class for purposes of efficiency; you
188 * should only access these members as part of an instantiation
189 * of the std::numeric_limits class.
191 struct __numeric_limits_base
193 /** This will be true for all fundamental types (which have
194 specializations), and false for everything else. */
195 static const bool is_specialized = false;
197 /** The number of @c radix digits that be represented without change: for
198 integer types, the number of non-sign bits in the mantissa; for
199 floating types, the number of @c radix digits in the mantissa. */
200 static const int digits = 0;
201 /** The number of base 10 digits that can be represented without change. */
202 static const int digits10 = 0;
203 /** True if the type is signed. */
204 static const bool is_signed = false;
205 /** True if the type is integer.
206 * @if maint
207 * Is this supposed to be "if the type is integral"?
208 * @endif
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."
214 [18.2.1.2]/15 */
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
228 number. */
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)
237 "Not a Number." */
238 static const bool has_quiet_NaN = false;
239 /** True if the type has a representation for a signaling
240 "Not a Number." */
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 tinyness 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 * @if maint
280 * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
281 * noted, but not incorporated in this documented (yet).
282 * @endif
284 template<typename _Tp>
285 struct numeric_limits : public __numeric_limits_base
287 /** The minimum finite value, or for floating types with
288 denormalization, the minimum positive normalized value. */
289 static _Tp min() throw() { return static_cast<_Tp>(0); }
290 /** The maximum finite value. */
291 static _Tp max() throw() { return static_cast<_Tp>(0); }
292 /** The @e machine @e epsilon: the difference between 1 and the least
293 value greater than 1 that is representable. */
294 static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
295 /** The maximum rounding error measurement (see LIA-1). */
296 static _Tp round_error() throw() { return static_cast<_Tp>(0); }
297 /** The representation of positive infinity, if @c has_infinity. */
298 static _Tp infinity() throw() { return static_cast<_Tp>(0); }
299 /** The representation of a quiet "Not a Number," if @c has_quiet_NaN. */
300 static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
301 /** The representation of a signaling "Not a Number," if
302 @c has_signaling_NaN. */
303 static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
304 /** The minimum positive denormalized value. For types where
305 @c has_denorm is false, this is the minimum positive normalized
306 value. */
307 static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
310 // Now there follow 15 explicit specializations. Yes, 15. Make sure
311 // you get the count right.
313 /// numeric_limits<bool> specialization.
314 template<>
315 struct numeric_limits<bool>
317 static const bool is_specialized = true;
319 static bool min() throw()
320 { return false; }
321 static bool max() throw()
322 { return true; }
324 static const int digits = 1;
325 static const int digits10 = 0;
326 static const bool is_signed = false;
327 static const bool is_integer = true;
328 static const bool is_exact = true;
329 static const int radix = 2;
330 static bool epsilon() throw()
331 { return false; }
332 static bool round_error() throw()
333 { return false; }
335 static const int min_exponent = 0;
336 static const int min_exponent10 = 0;
337 static const int max_exponent = 0;
338 static const int max_exponent10 = 0;
340 static const bool has_infinity = false;
341 static const bool has_quiet_NaN = false;
342 static const bool has_signaling_NaN = false;
343 static const float_denorm_style has_denorm = denorm_absent;
344 static const bool has_denorm_loss = false;
346 static bool infinity() throw()
347 { return false; }
348 static bool quiet_NaN() throw()
349 { return false; }
350 static bool signaling_NaN() throw()
351 { return false; }
352 static bool denorm_min() throw()
353 { return false; }
355 static const bool is_iec559 = false;
356 static const bool is_bounded = true;
357 static const bool is_modulo = false;
359 // It is not clear what it means for a boolean type to trap.
360 // This is a DR on the LWG issue list. Here, I use integer
361 // promotion semantics.
362 static const bool traps = __glibcxx_integral_traps;
363 static const bool tinyness_before = false;
364 static const float_round_style round_style = round_toward_zero;
367 /// numeric_limits<char> specialization.
368 template<>
369 struct numeric_limits<char>
371 static const bool is_specialized = true;
373 static char min() throw()
374 { return __glibcxx_min(char); }
375 static char max() throw()
376 { return __glibcxx_max(char); }
378 static const int digits = __glibcxx_digits (char);
379 static const int digits10 = __glibcxx_digits10 (char);
380 static const bool is_signed = __glibcxx_signed (char);
381 static const bool is_integer = true;
382 static const bool is_exact = true;
383 static const int radix = 2;
384 static char epsilon() throw()
385 { return 0; }
386 static char round_error() throw()
387 { return 0; }
389 static const int min_exponent = 0;
390 static const int min_exponent10 = 0;
391 static const int max_exponent = 0;
392 static const int max_exponent10 = 0;
394 static const bool has_infinity = false;
395 static const bool has_quiet_NaN = false;
396 static const bool has_signaling_NaN = false;
397 static const float_denorm_style has_denorm = denorm_absent;
398 static const bool has_denorm_loss = false;
400 static char infinity() throw()
401 { return char(); }
402 static char quiet_NaN() throw()
403 { return char(); }
404 static char signaling_NaN() throw()
405 { return char(); }
406 static char denorm_min() throw()
407 { return static_cast<char>(0); }
409 static const bool is_iec559 = false;
410 static const bool is_bounded = true;
411 static const bool is_modulo = true;
413 static const bool traps = __glibcxx_integral_traps;
414 static const bool tinyness_before = false;
415 static const float_round_style round_style = round_toward_zero;
418 /// numeric_limits<signed char> specialization.
419 template<>
420 struct numeric_limits<signed char>
422 static const bool is_specialized = true;
424 static signed char min() throw()
425 { return -__SCHAR_MAX__ - 1; }
426 static signed char max() throw()
427 { return __SCHAR_MAX__; }
429 static const int digits = __glibcxx_digits (signed char);
430 static const int digits10 = __glibcxx_digits10 (signed char);
431 static const bool is_signed = true;
432 static const bool is_integer = true;
433 static const bool is_exact = true;
434 static const int radix = 2;
435 static signed char epsilon() throw()
436 { return 0; }
437 static signed char round_error() throw()
438 { return 0; }
440 static const int min_exponent = 0;
441 static const int min_exponent10 = 0;
442 static const int max_exponent = 0;
443 static const int max_exponent10 = 0;
445 static const bool has_infinity = false;
446 static const bool has_quiet_NaN = false;
447 static const bool has_signaling_NaN = false;
448 static const float_denorm_style has_denorm = denorm_absent;
449 static const bool has_denorm_loss = false;
451 static signed char infinity() throw()
452 { return static_cast<signed char>(0); }
453 static signed char quiet_NaN() throw()
454 { return static_cast<signed char>(0); }
455 static signed char signaling_NaN() throw()
456 { return static_cast<signed char>(0); }
457 static signed char denorm_min() throw()
458 { return static_cast<signed char>(0); }
460 static const bool is_iec559 = false;
461 static const bool is_bounded = true;
462 static const bool is_modulo = true;
464 static const bool traps = __glibcxx_integral_traps;
465 static const bool tinyness_before = false;
466 static const float_round_style round_style = round_toward_zero;
469 /// numeric_limits<unsigned char> specialization.
470 template<>
471 struct numeric_limits<unsigned char>
473 static const bool is_specialized = true;
475 static unsigned char min() throw()
476 { return 0; }
477 static unsigned char max() throw()
478 { return __SCHAR_MAX__ * 2U + 1; }
480 static const int digits = __glibcxx_digits (unsigned char);
481 static const int digits10 = __glibcxx_digits10 (unsigned char);
482 static const bool is_signed = false;
483 static const bool is_integer = true;
484 static const bool is_exact = true;
485 static const int radix = 2;
486 static unsigned char epsilon() throw()
487 { return 0; }
488 static unsigned char round_error() throw()
489 { return 0; }
491 static const int min_exponent = 0;
492 static const int min_exponent10 = 0;
493 static const int max_exponent = 0;
494 static const int max_exponent10 = 0;
496 static const bool has_infinity = false;
497 static const bool has_quiet_NaN = false;
498 static const bool has_signaling_NaN = false;
499 static const float_denorm_style has_denorm = denorm_absent;
500 static const bool has_denorm_loss = false;
502 static unsigned char infinity() throw()
503 { return static_cast<unsigned char>(0); }
504 static unsigned char quiet_NaN() throw()
505 { return static_cast<unsigned char>(0); }
506 static unsigned char signaling_NaN() throw()
507 { return static_cast<unsigned char>(0); }
508 static unsigned char denorm_min() throw()
509 { return static_cast<unsigned char>(0); }
511 static const bool is_iec559 = false;
512 static const bool is_bounded = true;
513 static const bool is_modulo = true;
515 static const bool traps = __glibcxx_integral_traps;
516 static const bool tinyness_before = false;
517 static const float_round_style round_style = round_toward_zero;
520 /// numeric_limits<wchar_t> specialization.
521 template<>
522 struct numeric_limits<wchar_t>
524 static const bool is_specialized = true;
526 static wchar_t min() throw()
527 { return __glibcxx_min (wchar_t); }
528 static wchar_t max() throw()
529 { return __glibcxx_max (wchar_t); }
531 static const int digits = __glibcxx_digits (wchar_t);
532 static const int digits10 = __glibcxx_digits10 (wchar_t);
533 static const bool is_signed = __glibcxx_signed (wchar_t);
534 static const bool is_integer = true;
535 static const bool is_exact = true;
536 static const int radix = 2;
537 static wchar_t epsilon() throw()
538 { return 0; }
539 static wchar_t round_error() throw()
540 { return 0; }
542 static const int min_exponent = 0;
543 static const int min_exponent10 = 0;
544 static const int max_exponent = 0;
545 static const int max_exponent10 = 0;
547 static const bool has_infinity = false;
548 static const bool has_quiet_NaN = false;
549 static const bool has_signaling_NaN = false;
550 static const float_denorm_style has_denorm = denorm_absent;
551 static const bool has_denorm_loss = false;
553 static wchar_t infinity() throw()
554 { return wchar_t(); }
555 static wchar_t quiet_NaN() throw()
556 { return wchar_t(); }
557 static wchar_t signaling_NaN() throw()
558 { return wchar_t(); }
559 static wchar_t denorm_min() throw()
560 { return wchar_t(); }
562 static const bool is_iec559 = false;
563 static const bool is_bounded = true;
564 static const bool is_modulo = true;
566 static const bool traps = __glibcxx_integral_traps;
567 static const bool tinyness_before = false;
568 static const float_round_style round_style = round_toward_zero;
571 /// numeric_limits<short> specialization.
572 template<>
573 struct numeric_limits<short>
575 static const bool is_specialized = true;
577 static short min() throw()
578 { return -__SHRT_MAX__ - 1; }
579 static short max() throw()
580 { return __SHRT_MAX__; }
582 static const int digits = __glibcxx_digits (short);
583 static const int digits10 = __glibcxx_digits10 (short);
584 static const bool is_signed = true;
585 static const bool is_integer = true;
586 static const bool is_exact = true;
587 static const int radix = 2;
588 static short epsilon() throw()
589 { return 0; }
590 static short round_error() throw()
591 { return 0; }
593 static const int min_exponent = 0;
594 static const int min_exponent10 = 0;
595 static const int max_exponent = 0;
596 static const int max_exponent10 = 0;
598 static const bool has_infinity = false;
599 static const bool has_quiet_NaN = false;
600 static const bool has_signaling_NaN = false;
601 static const float_denorm_style has_denorm = denorm_absent;
602 static const bool has_denorm_loss = false;
604 static short infinity() throw()
605 { return short(); }
606 static short quiet_NaN() throw()
607 { return short(); }
608 static short signaling_NaN() throw()
609 { return short(); }
610 static short denorm_min() throw()
611 { return short(); }
613 static const bool is_iec559 = false;
614 static const bool is_bounded = true;
615 static const bool is_modulo = true;
617 static const bool traps = __glibcxx_integral_traps;
618 static const bool tinyness_before = false;
619 static const float_round_style round_style = round_toward_zero;
622 /// numeric_limits<unsigned short> specialization.
623 template<>
624 struct numeric_limits<unsigned short>
626 static const bool is_specialized = true;
628 static unsigned short min() throw()
629 { return 0; }
630 static unsigned short max() throw()
631 { return __SHRT_MAX__ * 2U + 1; }
633 static const int digits = __glibcxx_digits (unsigned short);
634 static const int digits10 = __glibcxx_digits10 (unsigned short);
635 static const bool is_signed = false;
636 static const bool is_integer = true;
637 static const bool is_exact = true;
638 static const int radix = 2;
639 static unsigned short epsilon() throw()
640 { return 0; }
641 static unsigned short round_error() throw()
642 { return 0; }
644 static const int min_exponent = 0;
645 static const int min_exponent10 = 0;
646 static const int max_exponent = 0;
647 static const int max_exponent10 = 0;
649 static const bool has_infinity = false;
650 static const bool has_quiet_NaN = false;
651 static const bool has_signaling_NaN = false;
652 static const float_denorm_style has_denorm = denorm_absent;
653 static const bool has_denorm_loss = false;
655 static unsigned short infinity() throw()
656 { return static_cast<unsigned short>(0); }
657 static unsigned short quiet_NaN() throw()
658 { return static_cast<unsigned short>(0); }
659 static unsigned short signaling_NaN() throw()
660 { return static_cast<unsigned short>(0); }
661 static unsigned short denorm_min() throw()
662 { return static_cast<unsigned short>(0); }
664 static const bool is_iec559 = false;
665 static const bool is_bounded = true;
666 static const bool is_modulo = true;
668 static const bool traps = __glibcxx_integral_traps;
669 static const bool tinyness_before = false;
670 static const float_round_style round_style = round_toward_zero;
673 /// numeric_limits<int> specialization.
674 template<>
675 struct numeric_limits<int>
677 static const bool is_specialized = true;
679 static int min() throw()
680 { return -__INT_MAX__ - 1; }
681 static int max() throw()
682 { return __INT_MAX__; }
684 static const int digits = __glibcxx_digits (int);
685 static const int digits10 = __glibcxx_digits10 (int);
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 int epsilon() throw()
691 { return 0; }
692 static int round_error() throw()
693 { return 0; }
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 int infinity() throw()
707 { return static_cast<int>(0); }
708 static int quiet_NaN() throw()
709 { return static_cast<int>(0); }
710 static int signaling_NaN() throw()
711 { return static_cast<int>(0); }
712 static int denorm_min() throw()
713 { return static_cast<int>(0); }
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 int> specialization.
725 template<>
726 struct numeric_limits<unsigned int>
728 static const bool is_specialized = true;
730 static unsigned int min() throw()
731 { return 0; }
732 static unsigned int max() throw()
733 { return __INT_MAX__ * 2U + 1; }
735 static const int digits = __glibcxx_digits (unsigned int);
736 static const int digits10 = __glibcxx_digits10 (unsigned int);
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 int epsilon() throw()
742 { return 0; }
743 static unsigned int round_error() throw()
744 { return 0; }
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 int infinity() throw()
758 { return static_cast<unsigned int>(0); }
759 static unsigned int quiet_NaN() throw()
760 { return static_cast<unsigned int>(0); }
761 static unsigned int signaling_NaN() throw()
762 { return static_cast<unsigned int>(0); }
763 static unsigned int denorm_min() throw()
764 { return static_cast<unsigned int>(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<long> specialization.
776 template<>
777 struct numeric_limits<long>
779 static const bool is_specialized = true;
781 static long min() throw()
782 { return -__LONG_MAX__ - 1; }
783 static long max() throw()
784 { return __LONG_MAX__; }
786 static const int digits = __glibcxx_digits (long);
787 static const int digits10 = __glibcxx_digits10 (long);
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 long epsilon() throw()
793 { return 0; }
794 static long round_error() throw()
795 { return 0; }
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 long infinity() throw()
809 { return static_cast<long>(0); }
810 static long quiet_NaN() throw()
811 { return static_cast<long>(0); }
812 static long signaling_NaN() throw()
813 { return static_cast<long>(0); }
814 static long denorm_min() throw()
815 { return static_cast<long>(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 long> specialization.
827 template<>
828 struct numeric_limits<unsigned long>
830 static const bool is_specialized = true;
832 static unsigned long min() throw()
833 { return 0; }
834 static unsigned long max() throw()
835 { return __LONG_MAX__ * 2UL + 1; }
837 static const int digits = __glibcxx_digits (unsigned long);
838 static const int digits10 = __glibcxx_digits10 (unsigned long);
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 long epsilon() throw()
844 { return 0; }
845 static unsigned long round_error() throw()
846 { return 0; }
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 long infinity() throw()
860 { return static_cast<unsigned long>(0); }
861 static unsigned long quiet_NaN() throw()
862 { return static_cast<unsigned long>(0); }
863 static unsigned long signaling_NaN() throw()
864 { return static_cast<unsigned long>(0); }
865 static unsigned long denorm_min() throw()
866 { return static_cast<unsigned long>(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 long> specialization.
878 template<>
879 struct numeric_limits<long long>
881 static const bool is_specialized = true;
883 static long long min() throw()
884 { return -__LONG_LONG_MAX__ - 1; }
885 static long long max() throw()
886 { return __LONG_LONG_MAX__; }
888 static const int digits = __glibcxx_digits (long long);
889 static const int digits10 = __glibcxx_digits10 (long 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 long epsilon() throw()
895 { return 0; }
896 static long long round_error() throw()
897 { return 0; }
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 long infinity() throw()
911 { return static_cast<long long>(0); }
912 static long long quiet_NaN() throw()
913 { return static_cast<long long>(0); }
914 static long long signaling_NaN() throw()
915 { return static_cast<long long>(0); }
916 static long long denorm_min() throw()
917 { return static_cast<long 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 long> specialization.
929 template<>
930 struct numeric_limits<unsigned long long>
932 static const bool is_specialized = true;
934 static unsigned long long min() throw()
935 { return 0; }
936 static unsigned long long max() throw()
937 { return __LONG_LONG_MAX__ * 2ULL + 1; }
939 static const int digits = __glibcxx_digits (unsigned long long);
940 static const int digits10 = __glibcxx_digits10 (unsigned long 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 long epsilon() throw()
946 { return 0; }
947 static unsigned long long round_error() throw()
948 { return 0; }
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 long infinity() throw()
962 { return static_cast<unsigned long long>(0); }
963 static unsigned long long quiet_NaN() throw()
964 { return static_cast<unsigned long long>(0); }
965 static unsigned long long signaling_NaN() throw()
966 { return static_cast<unsigned long long>(0); }
967 static unsigned long long denorm_min() throw()
968 { return static_cast<unsigned long 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<float> specialization.
980 template<>
981 struct numeric_limits<float>
983 static const bool is_specialized = true;
985 static float min() throw()
986 { return __FLT_MIN__; }
987 static float max() throw()
988 { return __FLT_MAX__; }
990 static const int digits = __FLT_MANT_DIG__;
991 static const int digits10 = __FLT_DIG__;
992 static const bool is_signed = true;
993 static const bool is_integer = false;
994 static const bool is_exact = false;
995 static const int radix = __FLT_RADIX__;
996 static float epsilon() throw()
997 { return __FLT_EPSILON__; }
998 static float round_error() throw()
999 { return 0.5F; }
1001 static const int min_exponent = __FLT_MIN_EXP__;
1002 static const int min_exponent10 = __FLT_MIN_10_EXP__;
1003 static const int max_exponent = __FLT_MAX_EXP__;
1004 static const int max_exponent10 = __FLT_MAX_10_EXP__;
1006 static const bool has_infinity = __FLT_HAS_INFINITY__;
1007 static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
1008 static const bool has_signaling_NaN = has_quiet_NaN;
1009 static const float_denorm_style has_denorm
1010 = __FLT_DENORM_MIN__ ? denorm_present : denorm_absent;
1011 static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
1013 static float infinity() throw()
1014 { return __builtin_huge_valf (); }
1015 static float quiet_NaN() throw()
1016 { return __builtin_nanf (""); }
1017 static float signaling_NaN() throw()
1018 { return __builtin_nansf (""); }
1019 static float denorm_min() throw()
1020 { return __FLT_DENORM_MIN__; }
1022 static const bool is_iec559
1023 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1024 static const bool is_bounded = true;
1025 static const bool is_modulo = false;
1027 static const bool traps = __glibcxx_float_traps;
1028 static const bool tinyness_before = __glibcxx_float_tinyness_before;
1029 static const float_round_style round_style = round_to_nearest;
1032 #undef __glibcxx_float_has_denorm_loss
1033 #undef __glibcxx_float_traps
1034 #undef __glibcxx_float_tinyness_before
1036 /// numeric_limits<double> specialization.
1037 template<>
1038 struct numeric_limits<double>
1040 static const bool is_specialized = true;
1042 static double min() throw()
1043 { return __DBL_MIN__; }
1044 static double max() throw()
1045 { return __DBL_MAX__; }
1047 static const int digits = __DBL_MANT_DIG__;
1048 static const int digits10 = __DBL_DIG__;
1049 static const bool is_signed = true;
1050 static const bool is_integer = false;
1051 static const bool is_exact = false;
1052 static const int radix = __FLT_RADIX__;
1053 static double epsilon() throw()
1054 { return __DBL_EPSILON__; }
1055 static double round_error() throw()
1056 { return 0.5; }
1058 static const int min_exponent = __DBL_MIN_EXP__;
1059 static const int min_exponent10 = __DBL_MIN_10_EXP__;
1060 static const int max_exponent = __DBL_MAX_EXP__;
1061 static const int max_exponent10 = __DBL_MAX_10_EXP__;
1063 static const bool has_infinity = __DBL_HAS_INFINITY__;
1064 static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
1065 static const bool has_signaling_NaN = has_quiet_NaN;
1066 static const float_denorm_style has_denorm
1067 = __DBL_DENORM_MIN__ ? denorm_present : denorm_absent;
1068 static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
1070 static double infinity() throw()
1071 { return __builtin_huge_val(); }
1072 static double quiet_NaN() throw()
1073 { return __builtin_nan (""); }
1074 static double signaling_NaN() throw()
1075 { return __builtin_nans (""); }
1076 static double denorm_min() throw()
1077 { return __DBL_DENORM_MIN__; }
1079 static const bool is_iec559
1080 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1081 static const bool is_bounded = true;
1082 static const bool is_modulo = false;
1084 static const bool traps = __glibcxx_double_traps;
1085 static const bool tinyness_before = __glibcxx_double_tinyness_before;
1086 static const float_round_style round_style = round_to_nearest;
1089 #undef __glibcxx_double_has_denorm_loss
1090 #undef __glibcxx_double_traps
1091 #undef __glibcxx_double_tinyness_before
1093 /// numeric_limits<long double> specialization.
1094 template<>
1095 struct numeric_limits<long double>
1097 static const bool is_specialized = true;
1099 static long double min() throw()
1100 { return __LDBL_MIN__; }
1101 static long double max() throw()
1102 { return __LDBL_MAX__; }
1104 static const int digits = __LDBL_MANT_DIG__;
1105 static const int digits10 = __LDBL_DIG__;
1106 static const bool is_signed = true;
1107 static const bool is_integer = false;
1108 static const bool is_exact = false;
1109 static const int radix = __FLT_RADIX__;
1110 static long double epsilon() throw()
1111 { return __LDBL_EPSILON__; }
1112 static long double round_error() throw()
1113 { return 0.5L; }
1115 static const int min_exponent = __LDBL_MIN_EXP__;
1116 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
1117 static const int max_exponent = __LDBL_MAX_EXP__;
1118 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
1120 static const bool has_infinity = __LDBL_HAS_INFINITY__;
1121 static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
1122 static const bool has_signaling_NaN = has_quiet_NaN;
1123 static const float_denorm_style has_denorm
1124 = __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent;
1125 static const bool has_denorm_loss
1126 = __glibcxx_long_double_has_denorm_loss;
1128 static long double infinity() throw()
1129 { return __builtin_huge_vall (); }
1130 static long double quiet_NaN() throw()
1131 { return __builtin_nanl (""); }
1132 static long double signaling_NaN() throw()
1133 { return __builtin_nansl (""); }
1134 static long double denorm_min() throw()
1135 { return __LDBL_DENORM_MIN__; }
1137 static const bool is_iec559
1138 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1139 static const bool is_bounded = true;
1140 static const bool is_modulo = false;
1142 static const bool traps = __glibcxx_long_double_traps;
1143 static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
1144 static const float_round_style round_style = round_to_nearest;
1147 #undef __glibcxx_long_double_has_denorm_loss
1148 #undef __glibcxx_long_double_traps
1149 #undef __glibcxx_long_double_tinyness_before
1151 } // namespace std
1153 #undef __glibcxx_signed
1154 #undef __glibcxx_min
1155 #undef __glibcxx_max
1156 #undef __glibcxx_digits
1157 #undef __glibcxx_digits10
1159 #endif // _GLIBCXX_NUMERIC_LIMITS