]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/std/limits
re PR libstdc++/42460 (man page errors for generated libstdc++ man pages)
[thirdparty/gcc.git] / libstdc++-v3 / include / std / limits
1 // The template and inlines for the numeric_limits classes. -*- C++ -*-
2
3 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 // 2008, 2009, 2010 Free Software Foundation, Inc.
5 //
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 3, or (at your option)
10 // any later version.
11
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.
16
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
20
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
25
26 /** @file limits
27 * This is a Standard C++ Library header.
28 */
29
30 // Note: this is not a conforming implementation.
31 // Written by Gabriel Dos Reis <gdr@codesourcery.com>
32
33 //
34 // ISO 14882:1998
35 // 18.2.1
36 //
37
38 #ifndef _GLIBCXX_NUMERIC_LIMITS
39 #define _GLIBCXX_NUMERIC_LIMITS 1
40
41 #pragma GCC system_header
42
43 #include <bits/c++config.h>
44
45 //
46 // The numeric_limits<> traits document implementation-defined aspects
47 // of fundamental arithmetic data types (integers and floating points).
48 // From Standard C++ point of view, there are 13 such types:
49 // * integers
50 // bool (1)
51 // char, signed char, unsigned char (3)
52 // short, unsigned short (2)
53 // int, unsigned (2)
54 // long, unsigned long (2)
55 //
56 // * floating points
57 // float (1)
58 // double (1)
59 // long double (1)
60 //
61 // GNU C++ understands (where supported by the host C-library)
62 // * integer
63 // long long, unsigned long long (2)
64 //
65 // which brings us to 15 fundamental arithmetic data types in GNU C++.
66 //
67 //
68 // Since a numeric_limits<> is a bit tricky to get right, we rely on
69 // an interface composed of macros which should be defined in config/os
70 // or config/cpu when they differ from the generic (read arbitrary)
71 // definitions given here.
72 //
73
74 // These values can be overridden in the target configuration file.
75 // The default values are appropriate for many 32-bit targets.
76
77 // GCC only intrinsically supports modulo integral types. The only remaining
78 // integral exceptional values is division by zero. Only targets that do not
79 // signal division by zero in some "hard to ignore" way should use false.
80 #ifndef __glibcxx_integral_traps
81 # define __glibcxx_integral_traps true
82 #endif
83
84 // float
85 //
86
87 // Default values. Should be overridden in configuration files if necessary.
88
89 #ifndef __glibcxx_float_has_denorm_loss
90 # define __glibcxx_float_has_denorm_loss false
91 #endif
92 #ifndef __glibcxx_float_traps
93 # define __glibcxx_float_traps false
94 #endif
95 #ifndef __glibcxx_float_tinyness_before
96 # define __glibcxx_float_tinyness_before false
97 #endif
98
99 // double
100
101 // Default values. Should be overridden in configuration files if necessary.
102
103 #ifndef __glibcxx_double_has_denorm_loss
104 # define __glibcxx_double_has_denorm_loss false
105 #endif
106 #ifndef __glibcxx_double_traps
107 # define __glibcxx_double_traps false
108 #endif
109 #ifndef __glibcxx_double_tinyness_before
110 # define __glibcxx_double_tinyness_before false
111 #endif
112
113 // long double
114
115 // Default values. Should be overridden in configuration files if necessary.
116
117 #ifndef __glibcxx_long_double_has_denorm_loss
118 # define __glibcxx_long_double_has_denorm_loss false
119 #endif
120 #ifndef __glibcxx_long_double_traps
121 # define __glibcxx_long_double_traps false
122 #endif
123 #ifndef __glibcxx_long_double_tinyness_before
124 # define __glibcxx_long_double_tinyness_before false
125 #endif
126
127 // You should not need to define any macros below this point.
128
129 #define __glibcxx_signed(T) ((T)(-1) < 0)
130
131 #define __glibcxx_min(T) \
132 (__glibcxx_signed (T) ? (T)1 << __glibcxx_digits (T) : (T)0)
133
134 #define __glibcxx_max(T) \
135 (__glibcxx_signed (T) ? \
136 (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
137
138 #define __glibcxx_digits(T) \
139 (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
140
141 // The fraction 643/2136 approximates log10(2) to 7 significant digits.
142 #define __glibcxx_digits10(T) \
143 (__glibcxx_digits (T) * 643 / 2136)
144
145
146 _GLIBCXX_BEGIN_NAMESPACE(std)
147
148 /**
149 * @brief Describes the rounding style for floating-point types.
150 *
151 * This is used in the std::numeric_limits class.
152 */
153 enum float_round_style
154 {
155 round_indeterminate = -1, ///< Self-explanatory.
156 round_toward_zero = 0, ///< Self-explanatory.
157 round_to_nearest = 1, ///< To the nearest representable value.
158 round_toward_infinity = 2, ///< Self-explanatory.
159 round_toward_neg_infinity = 3 ///< Self-explanatory.
160 };
161
162 /**
163 * @brief Describes the denormalization for floating-point types.
164 *
165 * These values represent the presence or absence of a variable number
166 * of exponent bits. This type is used in the std::numeric_limits class.
167 */
168 enum float_denorm_style
169 {
170 /// Indeterminate at compile time whether denormalized values are allowed.
171 denorm_indeterminate = -1,
172 /// The type does not allow denormalized values.
173 denorm_absent = 0,
174 /// The type allows denormalized values.
175 denorm_present = 1
176 };
177
178 /**
179 * @brief Part of std::numeric_limits.
180 *
181 * The @c static @c const members are usable as integral constant
182 * expressions.
183 *
184 * @note This is a separate class for purposes of efficiency; you
185 * should only access these members as part of an instantiation
186 * of the std::numeric_limits class.
187 */
188 struct __numeric_limits_base
189 {
190 /** This will be true for all fundamental types (which have
191 specializations), and false for everything else. */
192 static const bool is_specialized = false;
193
194 /** The number of @c radix digits that be represented without change: for
195 integer types, the number of non-sign bits in the mantissa; for
196 floating types, the number of @c radix digits in the mantissa. */
197 static const int digits = 0;
198 /** The number of base 10 digits that can be represented without change. */
199 static const int digits10 = 0;
200 /** True if the type is signed. */
201 static const bool is_signed = false;
202 /** True if the type is integer.
203 * Is this supposed to be <em>if the type is integral?</em>
204 */
205 static const bool is_integer = false;
206 /** True if the type uses an exact representation. <em>All integer types are
207 exact, but not all exact types are integer. For example, rational and
208 fixed-exponent representations are exact but not integer.</em>
209 [18.2.1.2]/15 */
210 static const bool is_exact = false;
211 /** For integer types, specifies the base of the representation. For
212 floating types, specifies the base of the exponent representation. */
213 static const int radix = 0;
214
215 /** The minimum negative integer such that @c radix raised to the power of
216 (one less than that integer) is a normalized floating point number. */
217 static const int min_exponent = 0;
218 /** The minimum negative integer such that 10 raised to that power is in
219 the range of normalized floating point numbers. */
220 static const int min_exponent10 = 0;
221 /** The maximum positive integer such that @c radix raised to the power of
222 (one less than that integer) is a representable finite floating point
223 number. */
224 static const int max_exponent = 0;
225 /** The maximum positive integer such that 10 raised to that power is in
226 the range of representable finite floating point numbers. */
227 static const int max_exponent10 = 0;
228
229 /** True if the type has a representation for positive infinity. */
230 static const bool has_infinity = false;
231 /** True if the type has a representation for a quiet (non-signaling)
232 <em>Not a Number</em>. */
233 static const bool has_quiet_NaN = false;
234 /** True if the type has a representation for a signaling
235 <em>Not a Number</em>. */
236 static const bool has_signaling_NaN = false;
237 /** See std::float_denorm_style for more information. */
238 static const float_denorm_style has_denorm = denorm_absent;
239 /** <em>True if loss of accuracy is detected as a denormalization loss,
240 rather than as an inexact result.</em> [18.2.1.2]/42 */
241 static const bool has_denorm_loss = false;
242
243 /** True if-and-only-if the type adheres to the IEC 559 standard, also
244 known as IEEE 754. (Only makes sense for floating point types.) */
245 static const bool is_iec559 = false;
246 /** <em>True if the set of values representable by the type is
247 finite. All built-in types are bounded, this member would be
248 false for arbitrary precision types.</em> [18.2.1.2]/54 */
249 static const bool is_bounded = false;
250 /** True if the type is @e modulo, that is, if it is possible to add two
251 positive numbers and have a result that wraps around to a third number
252 that is less. Typically false for floating types, true for unsigned
253 integers, and true for signed integers. */
254 static const bool is_modulo = false;
255
256 /** True if trapping is implemented for this type. */
257 static const bool traps = false;
258 /** True if tininess is detected before rounding. (see IEC 559) */
259 static const bool tinyness_before = false;
260 /** See std::float_round_style for more information. This is only
261 meaningful for floating types; integer types will all be
262 round_toward_zero. */
263 static const float_round_style round_style = round_toward_zero;
264 };
265
266 /**
267 * @brief Properties of fundamental types.
268 *
269 * This class allows a program to obtain information about the
270 * representation of a fundamental type on a given platform. For
271 * non-fundamental types, the functions will return 0 and the data
272 * members will all be @c false.
273 *
274 * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
275 * noted, but not incorporated in this documented (yet).
276 */
277 template<typename _Tp>
278 struct numeric_limits : public __numeric_limits_base
279 {
280 /** The minimum finite value, or for floating types with
281 denormalization, the minimum positive normalized value. */
282 static _Tp min() throw() { return static_cast<_Tp>(0); }
283 /** The maximum finite value. */
284 static _Tp max() throw() { return static_cast<_Tp>(0); }
285 /** The @e machine @e epsilon: the difference between 1 and the least
286 value greater than 1 that is representable. */
287 static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
288 /** The maximum rounding error measurement (see LIA-1). */
289 static _Tp round_error() throw() { return static_cast<_Tp>(0); }
290 /** The representation of positive infinity, if @c has_infinity. */
291 static _Tp infinity() throw() { return static_cast<_Tp>(0); }
292
293 /** The representation of a quiet <em>Not a Number</em>,
294 if @c has_quiet_NaN. */
295 static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
296 /** The representation of a signaling <em>Not a Number</em>, if
297 @c has_signaling_NaN. */
298 static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
299 /** The minimum positive denormalized value. For types where
300 @c has_denorm is false, this is the minimum positive normalized
301 value. */
302 static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
303 };
304
305 // Now there follow 15 explicit specializations. Yes, 15. Make sure
306 // you get the count right.
307
308 /// numeric_limits<bool> specialization.
309 template<>
310 struct numeric_limits<bool>
311 {
312 static const bool is_specialized = true;
313
314 static bool min() throw()
315 { return false; }
316 static bool max() throw()
317 { return true; }
318
319 static const int digits = 1;
320 static const int digits10 = 0;
321 static const bool is_signed = false;
322 static const bool is_integer = true;
323 static const bool is_exact = true;
324 static const int radix = 2;
325 static bool epsilon() throw()
326 { return false; }
327 static bool round_error() throw()
328 { return false; }
329
330 static const int min_exponent = 0;
331 static const int min_exponent10 = 0;
332 static const int max_exponent = 0;
333 static const int max_exponent10 = 0;
334
335 static const bool has_infinity = false;
336 static const bool has_quiet_NaN = false;
337 static const bool has_signaling_NaN = false;
338 static const float_denorm_style has_denorm = denorm_absent;
339 static const bool has_denorm_loss = false;
340
341 static bool infinity() throw()
342 { return false; }
343 static bool quiet_NaN() throw()
344 { return false; }
345 static bool signaling_NaN() throw()
346 { return false; }
347 static bool denorm_min() throw()
348 { return false; }
349
350 static const bool is_iec559 = false;
351 static const bool is_bounded = true;
352 static const bool is_modulo = false;
353
354 // It is not clear what it means for a boolean type to trap.
355 // This is a DR on the LWG issue list. Here, I use integer
356 // promotion semantics.
357 static const bool traps = __glibcxx_integral_traps;
358 static const bool tinyness_before = false;
359 static const float_round_style round_style = round_toward_zero;
360 };
361
362 /// numeric_limits<char> specialization.
363 template<>
364 struct numeric_limits<char>
365 {
366 static const bool is_specialized = true;
367
368 static char min() throw()
369 { return __glibcxx_min(char); }
370 static char max() throw()
371 { return __glibcxx_max(char); }
372
373 static const int digits = __glibcxx_digits (char);
374 static const int digits10 = __glibcxx_digits10 (char);
375 static const bool is_signed = __glibcxx_signed (char);
376 static const bool is_integer = true;
377 static const bool is_exact = true;
378 static const int radix = 2;
379 static char epsilon() throw()
380 { return 0; }
381 static char round_error() throw()
382 { return 0; }
383
384 static const int min_exponent = 0;
385 static const int min_exponent10 = 0;
386 static const int max_exponent = 0;
387 static const int max_exponent10 = 0;
388
389 static const bool has_infinity = false;
390 static const bool has_quiet_NaN = false;
391 static const bool has_signaling_NaN = false;
392 static const float_denorm_style has_denorm = denorm_absent;
393 static const bool has_denorm_loss = false;
394
395 static char infinity() throw()
396 { return char(); }
397 static char quiet_NaN() throw()
398 { return char(); }
399 static char signaling_NaN() throw()
400 { return char(); }
401 static char denorm_min() throw()
402 { return static_cast<char>(0); }
403
404 static const bool is_iec559 = false;
405 static const bool is_bounded = true;
406 static const bool is_modulo = true;
407
408 static const bool traps = __glibcxx_integral_traps;
409 static const bool tinyness_before = false;
410 static const float_round_style round_style = round_toward_zero;
411 };
412
413 /// numeric_limits<signed char> specialization.
414 template<>
415 struct numeric_limits<signed char>
416 {
417 static const bool is_specialized = true;
418
419 static signed char min() throw()
420 { return -__SCHAR_MAX__ - 1; }
421 static signed char max() throw()
422 { return __SCHAR_MAX__; }
423
424 static const int digits = __glibcxx_digits (signed char);
425 static const int digits10 = __glibcxx_digits10 (signed char);
426 static const bool is_signed = true;
427 static const bool is_integer = true;
428 static const bool is_exact = true;
429 static const int radix = 2;
430 static signed char epsilon() throw()
431 { return 0; }
432 static signed char round_error() throw()
433 { return 0; }
434
435 static const int min_exponent = 0;
436 static const int min_exponent10 = 0;
437 static const int max_exponent = 0;
438 static const int max_exponent10 = 0;
439
440 static const bool has_infinity = false;
441 static const bool has_quiet_NaN = false;
442 static const bool has_signaling_NaN = false;
443 static const float_denorm_style has_denorm = denorm_absent;
444 static const bool has_denorm_loss = false;
445
446 static signed char infinity() throw()
447 { return static_cast<signed char>(0); }
448 static signed char quiet_NaN() throw()
449 { return static_cast<signed char>(0); }
450 static signed char signaling_NaN() throw()
451 { return static_cast<signed char>(0); }
452 static signed char denorm_min() throw()
453 { return static_cast<signed char>(0); }
454
455 static const bool is_iec559 = false;
456 static const bool is_bounded = true;
457 static const bool is_modulo = true;
458
459 static const bool traps = __glibcxx_integral_traps;
460 static const bool tinyness_before = false;
461 static const float_round_style round_style = round_toward_zero;
462 };
463
464 /// numeric_limits<unsigned char> specialization.
465 template<>
466 struct numeric_limits<unsigned char>
467 {
468 static const bool is_specialized = true;
469
470 static unsigned char min() throw()
471 { return 0; }
472 static unsigned char max() throw()
473 { return __SCHAR_MAX__ * 2U + 1; }
474
475 static const int digits = __glibcxx_digits (unsigned char);
476 static const int digits10 = __glibcxx_digits10 (unsigned char);
477 static const bool is_signed = false;
478 static const bool is_integer = true;
479 static const bool is_exact = true;
480 static const int radix = 2;
481 static unsigned char epsilon() throw()
482 { return 0; }
483 static unsigned char round_error() throw()
484 { return 0; }
485
486 static const int min_exponent = 0;
487 static const int min_exponent10 = 0;
488 static const int max_exponent = 0;
489 static const int max_exponent10 = 0;
490
491 static const bool has_infinity = false;
492 static const bool has_quiet_NaN = false;
493 static const bool has_signaling_NaN = false;
494 static const float_denorm_style has_denorm = denorm_absent;
495 static const bool has_denorm_loss = false;
496
497 static unsigned char infinity() throw()
498 { return static_cast<unsigned char>(0); }
499 static unsigned char quiet_NaN() throw()
500 { return static_cast<unsigned char>(0); }
501 static unsigned char signaling_NaN() throw()
502 { return static_cast<unsigned char>(0); }
503 static unsigned char denorm_min() throw()
504 { return static_cast<unsigned char>(0); }
505
506 static const bool is_iec559 = false;
507 static const bool is_bounded = true;
508 static const bool is_modulo = true;
509
510 static const bool traps = __glibcxx_integral_traps;
511 static const bool tinyness_before = false;
512 static const float_round_style round_style = round_toward_zero;
513 };
514
515 /// numeric_limits<wchar_t> specialization.
516 template<>
517 struct numeric_limits<wchar_t>
518 {
519 static const bool is_specialized = true;
520
521 static wchar_t min() throw()
522 { return __glibcxx_min (wchar_t); }
523 static wchar_t max() throw()
524 { return __glibcxx_max (wchar_t); }
525
526 static const int digits = __glibcxx_digits (wchar_t);
527 static const int digits10 = __glibcxx_digits10 (wchar_t);
528 static const bool is_signed = __glibcxx_signed (wchar_t);
529 static const bool is_integer = true;
530 static const bool is_exact = true;
531 static const int radix = 2;
532 static wchar_t epsilon() throw()
533 { return 0; }
534 static wchar_t round_error() throw()
535 { return 0; }
536
537 static const int min_exponent = 0;
538 static const int min_exponent10 = 0;
539 static const int max_exponent = 0;
540 static const int max_exponent10 = 0;
541
542 static const bool has_infinity = false;
543 static const bool has_quiet_NaN = false;
544 static const bool has_signaling_NaN = false;
545 static const float_denorm_style has_denorm = denorm_absent;
546 static const bool has_denorm_loss = false;
547
548 static wchar_t infinity() throw()
549 { return wchar_t(); }
550 static wchar_t quiet_NaN() throw()
551 { return wchar_t(); }
552 static wchar_t signaling_NaN() throw()
553 { return wchar_t(); }
554 static wchar_t denorm_min() throw()
555 { return wchar_t(); }
556
557 static const bool is_iec559 = false;
558 static const bool is_bounded = true;
559 static const bool is_modulo = true;
560
561 static const bool traps = __glibcxx_integral_traps;
562 static const bool tinyness_before = false;
563 static const float_round_style round_style = round_toward_zero;
564 };
565
566 #ifdef __GXX_EXPERIMENTAL_CXX0X__
567 /// numeric_limits<char16_t> specialization.
568 template<>
569 struct numeric_limits<char16_t>
570 {
571 static const bool is_specialized = true;
572
573 static char16_t min() throw()
574 { return __glibcxx_min (char16_t); }
575 static char16_t max() throw()
576 { return __glibcxx_max (char16_t); }
577
578 static const int digits = __glibcxx_digits (char16_t);
579 static const int digits10 = __glibcxx_digits10 (char16_t);
580 static const bool is_signed = __glibcxx_signed (char16_t);
581 static const bool is_integer = true;
582 static const bool is_exact = true;
583 static const int radix = 2;
584 static char16_t epsilon() throw()
585 { return 0; }
586 static char16_t round_error() throw()
587 { return 0; }
588
589 static const int min_exponent = 0;
590 static const int min_exponent10 = 0;
591 static const int max_exponent = 0;
592 static const int max_exponent10 = 0;
593
594 static const bool has_infinity = false;
595 static const bool has_quiet_NaN = false;
596 static const bool has_signaling_NaN = false;
597 static const float_denorm_style has_denorm = denorm_absent;
598 static const bool has_denorm_loss = false;
599
600 static char16_t infinity() throw()
601 { return char16_t(); }
602 static char16_t quiet_NaN() throw()
603 { return char16_t(); }
604 static char16_t signaling_NaN() throw()
605 { return char16_t(); }
606 static char16_t denorm_min() throw()
607 { return char16_t(); }
608
609 static const bool is_iec559 = false;
610 static const bool is_bounded = true;
611 static const bool is_modulo = true;
612
613 static const bool traps = __glibcxx_integral_traps;
614 static const bool tinyness_before = false;
615 static const float_round_style round_style = round_toward_zero;
616 };
617
618 /// numeric_limits<char32_t> specialization.
619 template<>
620 struct numeric_limits<char32_t>
621 {
622 static const bool is_specialized = true;
623
624 static char32_t min() throw()
625 { return __glibcxx_min (char32_t); }
626 static char32_t max() throw()
627 { return __glibcxx_max (char32_t); }
628
629 static const int digits = __glibcxx_digits (char32_t);
630 static const int digits10 = __glibcxx_digits10 (char32_t);
631 static const bool is_signed = __glibcxx_signed (char32_t);
632 static const bool is_integer = true;
633 static const bool is_exact = true;
634 static const int radix = 2;
635 static char32_t epsilon() throw()
636 { return 0; }
637 static char32_t round_error() throw()
638 { return 0; }
639
640 static const int min_exponent = 0;
641 static const int min_exponent10 = 0;
642 static const int max_exponent = 0;
643 static const int max_exponent10 = 0;
644
645 static const bool has_infinity = false;
646 static const bool has_quiet_NaN = false;
647 static const bool has_signaling_NaN = false;
648 static const float_denorm_style has_denorm = denorm_absent;
649 static const bool has_denorm_loss = false;
650
651 static char32_t infinity() throw()
652 { return char32_t(); }
653 static char32_t quiet_NaN() throw()
654 { return char32_t(); }
655 static char32_t signaling_NaN() throw()
656 { return char32_t(); }
657 static char32_t denorm_min() throw()
658 { return char32_t(); }
659
660 static const bool is_iec559 = false;
661 static const bool is_bounded = true;
662 static const bool is_modulo = true;
663
664 static const bool traps = __glibcxx_integral_traps;
665 static const bool tinyness_before = false;
666 static const float_round_style round_style = round_toward_zero;
667 };
668 #endif
669
670 /// numeric_limits<short> specialization.
671 template<>
672 struct numeric_limits<short>
673 {
674 static const bool is_specialized = true;
675
676 static short min() throw()
677 { return -__SHRT_MAX__ - 1; }
678 static short max() throw()
679 { return __SHRT_MAX__; }
680
681 static const int digits = __glibcxx_digits (short);
682 static const int digits10 = __glibcxx_digits10 (short);
683 static const bool is_signed = true;
684 static const bool is_integer = true;
685 static const bool is_exact = true;
686 static const int radix = 2;
687 static short epsilon() throw()
688 { return 0; }
689 static short round_error() throw()
690 { return 0; }
691
692 static const int min_exponent = 0;
693 static const int min_exponent10 = 0;
694 static const int max_exponent = 0;
695 static const int max_exponent10 = 0;
696
697 static const bool has_infinity = false;
698 static const bool has_quiet_NaN = false;
699 static const bool has_signaling_NaN = false;
700 static const float_denorm_style has_denorm = denorm_absent;
701 static const bool has_denorm_loss = false;
702
703 static short infinity() throw()
704 { return short(); }
705 static short quiet_NaN() throw()
706 { return short(); }
707 static short signaling_NaN() throw()
708 { return short(); }
709 static short denorm_min() throw()
710 { return short(); }
711
712 static const bool is_iec559 = false;
713 static const bool is_bounded = true;
714 static const bool is_modulo = true;
715
716 static const bool traps = __glibcxx_integral_traps;
717 static const bool tinyness_before = false;
718 static const float_round_style round_style = round_toward_zero;
719 };
720
721 /// numeric_limits<unsigned short> specialization.
722 template<>
723 struct numeric_limits<unsigned short>
724 {
725 static const bool is_specialized = true;
726
727 static unsigned short min() throw()
728 { return 0; }
729 static unsigned short max() throw()
730 { return __SHRT_MAX__ * 2U + 1; }
731
732 static const int digits = __glibcxx_digits (unsigned short);
733 static const int digits10 = __glibcxx_digits10 (unsigned short);
734 static const bool is_signed = false;
735 static const bool is_integer = true;
736 static const bool is_exact = true;
737 static const int radix = 2;
738 static unsigned short epsilon() throw()
739 { return 0; }
740 static unsigned short round_error() throw()
741 { return 0; }
742
743 static const int min_exponent = 0;
744 static const int min_exponent10 = 0;
745 static const int max_exponent = 0;
746 static const int max_exponent10 = 0;
747
748 static const bool has_infinity = false;
749 static const bool has_quiet_NaN = false;
750 static const bool has_signaling_NaN = false;
751 static const float_denorm_style has_denorm = denorm_absent;
752 static const bool has_denorm_loss = false;
753
754 static unsigned short infinity() throw()
755 { return static_cast<unsigned short>(0); }
756 static unsigned short quiet_NaN() throw()
757 { return static_cast<unsigned short>(0); }
758 static unsigned short signaling_NaN() throw()
759 { return static_cast<unsigned short>(0); }
760 static unsigned short denorm_min() throw()
761 { return static_cast<unsigned short>(0); }
762
763 static const bool is_iec559 = false;
764 static const bool is_bounded = true;
765 static const bool is_modulo = true;
766
767 static const bool traps = __glibcxx_integral_traps;
768 static const bool tinyness_before = false;
769 static const float_round_style round_style = round_toward_zero;
770 };
771
772 /// numeric_limits<int> specialization.
773 template<>
774 struct numeric_limits<int>
775 {
776 static const bool is_specialized = true;
777
778 static int min() throw()
779 { return -__INT_MAX__ - 1; }
780 static int max() throw()
781 { return __INT_MAX__; }
782
783 static const int digits = __glibcxx_digits (int);
784 static const int digits10 = __glibcxx_digits10 (int);
785 static const bool is_signed = true;
786 static const bool is_integer = true;
787 static const bool is_exact = true;
788 static const int radix = 2;
789 static int epsilon() throw()
790 { return 0; }
791 static int round_error() throw()
792 { return 0; }
793
794 static const int min_exponent = 0;
795 static const int min_exponent10 = 0;
796 static const int max_exponent = 0;
797 static const int max_exponent10 = 0;
798
799 static const bool has_infinity = false;
800 static const bool has_quiet_NaN = false;
801 static const bool has_signaling_NaN = false;
802 static const float_denorm_style has_denorm = denorm_absent;
803 static const bool has_denorm_loss = false;
804
805 static int infinity() throw()
806 { return static_cast<int>(0); }
807 static int quiet_NaN() throw()
808 { return static_cast<int>(0); }
809 static int signaling_NaN() throw()
810 { return static_cast<int>(0); }
811 static int denorm_min() throw()
812 { return static_cast<int>(0); }
813
814 static const bool is_iec559 = false;
815 static const bool is_bounded = true;
816 static const bool is_modulo = true;
817
818 static const bool traps = __glibcxx_integral_traps;
819 static const bool tinyness_before = false;
820 static const float_round_style round_style = round_toward_zero;
821 };
822
823 /// numeric_limits<unsigned int> specialization.
824 template<>
825 struct numeric_limits<unsigned int>
826 {
827 static const bool is_specialized = true;
828
829 static unsigned int min() throw()
830 { return 0; }
831 static unsigned int max() throw()
832 { return __INT_MAX__ * 2U + 1; }
833
834 static const int digits = __glibcxx_digits (unsigned int);
835 static const int digits10 = __glibcxx_digits10 (unsigned int);
836 static const bool is_signed = false;
837 static const bool is_integer = true;
838 static const bool is_exact = true;
839 static const int radix = 2;
840 static unsigned int epsilon() throw()
841 { return 0; }
842 static unsigned int round_error() throw()
843 { return 0; }
844
845 static const int min_exponent = 0;
846 static const int min_exponent10 = 0;
847 static const int max_exponent = 0;
848 static const int max_exponent10 = 0;
849
850 static const bool has_infinity = false;
851 static const bool has_quiet_NaN = false;
852 static const bool has_signaling_NaN = false;
853 static const float_denorm_style has_denorm = denorm_absent;
854 static const bool has_denorm_loss = false;
855
856 static unsigned int infinity() throw()
857 { return static_cast<unsigned int>(0); }
858 static unsigned int quiet_NaN() throw()
859 { return static_cast<unsigned int>(0); }
860 static unsigned int signaling_NaN() throw()
861 { return static_cast<unsigned int>(0); }
862 static unsigned int denorm_min() throw()
863 { return static_cast<unsigned int>(0); }
864
865 static const bool is_iec559 = false;
866 static const bool is_bounded = true;
867 static const bool is_modulo = true;
868
869 static const bool traps = __glibcxx_integral_traps;
870 static const bool tinyness_before = false;
871 static const float_round_style round_style = round_toward_zero;
872 };
873
874 /// numeric_limits<long> specialization.
875 template<>
876 struct numeric_limits<long>
877 {
878 static const bool is_specialized = true;
879
880 static long min() throw()
881 { return -__LONG_MAX__ - 1; }
882 static long max() throw()
883 { return __LONG_MAX__; }
884
885 static const int digits = __glibcxx_digits (long);
886 static const int digits10 = __glibcxx_digits10 (long);
887 static const bool is_signed = true;
888 static const bool is_integer = true;
889 static const bool is_exact = true;
890 static const int radix = 2;
891 static long epsilon() throw()
892 { return 0; }
893 static long round_error() throw()
894 { return 0; }
895
896 static const int min_exponent = 0;
897 static const int min_exponent10 = 0;
898 static const int max_exponent = 0;
899 static const int max_exponent10 = 0;
900
901 static const bool has_infinity = false;
902 static const bool has_quiet_NaN = false;
903 static const bool has_signaling_NaN = false;
904 static const float_denorm_style has_denorm = denorm_absent;
905 static const bool has_denorm_loss = false;
906
907 static long infinity() throw()
908 { return static_cast<long>(0); }
909 static long quiet_NaN() throw()
910 { return static_cast<long>(0); }
911 static long signaling_NaN() throw()
912 { return static_cast<long>(0); }
913 static long denorm_min() throw()
914 { return static_cast<long>(0); }
915
916 static const bool is_iec559 = false;
917 static const bool is_bounded = true;
918 static const bool is_modulo = true;
919
920 static const bool traps = __glibcxx_integral_traps;
921 static const bool tinyness_before = false;
922 static const float_round_style round_style = round_toward_zero;
923 };
924
925 /// numeric_limits<unsigned long> specialization.
926 template<>
927 struct numeric_limits<unsigned long>
928 {
929 static const bool is_specialized = true;
930
931 static unsigned long min() throw()
932 { return 0; }
933 static unsigned long max() throw()
934 { return __LONG_MAX__ * 2UL + 1; }
935
936 static const int digits = __glibcxx_digits (unsigned long);
937 static const int digits10 = __glibcxx_digits10 (unsigned long);
938 static const bool is_signed = false;
939 static const bool is_integer = true;
940 static const bool is_exact = true;
941 static const int radix = 2;
942 static unsigned long epsilon() throw()
943 { return 0; }
944 static unsigned long round_error() throw()
945 { return 0; }
946
947 static const int min_exponent = 0;
948 static const int min_exponent10 = 0;
949 static const int max_exponent = 0;
950 static const int max_exponent10 = 0;
951
952 static const bool has_infinity = false;
953 static const bool has_quiet_NaN = false;
954 static const bool has_signaling_NaN = false;
955 static const float_denorm_style has_denorm = denorm_absent;
956 static const bool has_denorm_loss = false;
957
958 static unsigned long infinity() throw()
959 { return static_cast<unsigned long>(0); }
960 static unsigned long quiet_NaN() throw()
961 { return static_cast<unsigned long>(0); }
962 static unsigned long signaling_NaN() throw()
963 { return static_cast<unsigned long>(0); }
964 static unsigned long denorm_min() throw()
965 { return static_cast<unsigned long>(0); }
966
967 static const bool is_iec559 = false;
968 static const bool is_bounded = true;
969 static const bool is_modulo = true;
970
971 static const bool traps = __glibcxx_integral_traps;
972 static const bool tinyness_before = false;
973 static const float_round_style round_style = round_toward_zero;
974 };
975
976 /// numeric_limits<long long> specialization.
977 template<>
978 struct numeric_limits<long long>
979 {
980 static const bool is_specialized = true;
981
982 static long long min() throw()
983 { return -__LONG_LONG_MAX__ - 1; }
984 static long long max() throw()
985 { return __LONG_LONG_MAX__; }
986
987 static const int digits = __glibcxx_digits (long long);
988 static const int digits10 = __glibcxx_digits10 (long long);
989 static const bool is_signed = true;
990 static const bool is_integer = true;
991 static const bool is_exact = true;
992 static const int radix = 2;
993 static long long epsilon() throw()
994 { return 0; }
995 static long long round_error() throw()
996 { return 0; }
997
998 static const int min_exponent = 0;
999 static const int min_exponent10 = 0;
1000 static const int max_exponent = 0;
1001 static const int max_exponent10 = 0;
1002
1003 static const bool has_infinity = false;
1004 static const bool has_quiet_NaN = false;
1005 static const bool has_signaling_NaN = false;
1006 static const float_denorm_style has_denorm = denorm_absent;
1007 static const bool has_denorm_loss = false;
1008
1009 static long long infinity() throw()
1010 { return static_cast<long long>(0); }
1011 static long long quiet_NaN() throw()
1012 { return static_cast<long long>(0); }
1013 static long long signaling_NaN() throw()
1014 { return static_cast<long long>(0); }
1015 static long long denorm_min() throw()
1016 { return static_cast<long long>(0); }
1017
1018 static const bool is_iec559 = false;
1019 static const bool is_bounded = true;
1020 static const bool is_modulo = true;
1021
1022 static const bool traps = __glibcxx_integral_traps;
1023 static const bool tinyness_before = false;
1024 static const float_round_style round_style = round_toward_zero;
1025 };
1026
1027 /// numeric_limits<unsigned long long> specialization.
1028 template<>
1029 struct numeric_limits<unsigned long long>
1030 {
1031 static const bool is_specialized = true;
1032
1033 static unsigned long long min() throw()
1034 { return 0; }
1035 static unsigned long long max() throw()
1036 { return __LONG_LONG_MAX__ * 2ULL + 1; }
1037
1038 static const int digits = __glibcxx_digits (unsigned long long);
1039 static const int digits10 = __glibcxx_digits10 (unsigned long long);
1040 static const bool is_signed = false;
1041 static const bool is_integer = true;
1042 static const bool is_exact = true;
1043 static const int radix = 2;
1044 static unsigned long long epsilon() throw()
1045 { return 0; }
1046 static unsigned long long round_error() throw()
1047 { return 0; }
1048
1049 static const int min_exponent = 0;
1050 static const int min_exponent10 = 0;
1051 static const int max_exponent = 0;
1052 static const int max_exponent10 = 0;
1053
1054 static const bool has_infinity = false;
1055 static const bool has_quiet_NaN = false;
1056 static const bool has_signaling_NaN = false;
1057 static const float_denorm_style has_denorm = denorm_absent;
1058 static const bool has_denorm_loss = false;
1059
1060 static unsigned long long infinity() throw()
1061 { return static_cast<unsigned long long>(0); }
1062 static unsigned long long quiet_NaN() throw()
1063 { return static_cast<unsigned long long>(0); }
1064 static unsigned long long signaling_NaN() throw()
1065 { return static_cast<unsigned long long>(0); }
1066 static unsigned long long denorm_min() throw()
1067 { return static_cast<unsigned long long>(0); }
1068
1069 static const bool is_iec559 = false;
1070 static const bool is_bounded = true;
1071 static const bool is_modulo = true;
1072
1073 static const bool traps = __glibcxx_integral_traps;
1074 static const bool tinyness_before = false;
1075 static const float_round_style round_style = round_toward_zero;
1076 };
1077
1078 /// numeric_limits<float> specialization.
1079 template<>
1080 struct numeric_limits<float>
1081 {
1082 static const bool is_specialized = true;
1083
1084 static float min() throw()
1085 { return __FLT_MIN__; }
1086 static float max() throw()
1087 { return __FLT_MAX__; }
1088
1089 static const int digits = __FLT_MANT_DIG__;
1090 static const int digits10 = __FLT_DIG__;
1091 static const bool is_signed = true;
1092 static const bool is_integer = false;
1093 static const bool is_exact = false;
1094 static const int radix = __FLT_RADIX__;
1095 static float epsilon() throw()
1096 { return __FLT_EPSILON__; }
1097 static float round_error() throw()
1098 { return 0.5F; }
1099
1100 static const int min_exponent = __FLT_MIN_EXP__;
1101 static const int min_exponent10 = __FLT_MIN_10_EXP__;
1102 static const int max_exponent = __FLT_MAX_EXP__;
1103 static const int max_exponent10 = __FLT_MAX_10_EXP__;
1104
1105 static const bool has_infinity = __FLT_HAS_INFINITY__;
1106 static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
1107 static const bool has_signaling_NaN = has_quiet_NaN;
1108 static const float_denorm_style has_denorm
1109 = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
1110 static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
1111
1112 static float infinity() throw()
1113 { return __builtin_huge_valf (); }
1114 static float quiet_NaN() throw()
1115 { return __builtin_nanf (""); }
1116 static float signaling_NaN() throw()
1117 { return __builtin_nansf (""); }
1118 static float denorm_min() throw()
1119 { return __FLT_DENORM_MIN__; }
1120
1121 static const bool is_iec559
1122 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1123 static const bool is_bounded = true;
1124 static const bool is_modulo = false;
1125
1126 static const bool traps = __glibcxx_float_traps;
1127 static const bool tinyness_before = __glibcxx_float_tinyness_before;
1128 static const float_round_style round_style = round_to_nearest;
1129 };
1130
1131 #undef __glibcxx_float_has_denorm_loss
1132 #undef __glibcxx_float_traps
1133 #undef __glibcxx_float_tinyness_before
1134
1135 /// numeric_limits<double> specialization.
1136 template<>
1137 struct numeric_limits<double>
1138 {
1139 static const bool is_specialized = true;
1140
1141 static double min() throw()
1142 { return __DBL_MIN__; }
1143 static double max() throw()
1144 { return __DBL_MAX__; }
1145
1146 static const int digits = __DBL_MANT_DIG__;
1147 static const int digits10 = __DBL_DIG__;
1148 static const bool is_signed = true;
1149 static const bool is_integer = false;
1150 static const bool is_exact = false;
1151 static const int radix = __FLT_RADIX__;
1152 static double epsilon() throw()
1153 { return __DBL_EPSILON__; }
1154 static double round_error() throw()
1155 { return 0.5; }
1156
1157 static const int min_exponent = __DBL_MIN_EXP__;
1158 static const int min_exponent10 = __DBL_MIN_10_EXP__;
1159 static const int max_exponent = __DBL_MAX_EXP__;
1160 static const int max_exponent10 = __DBL_MAX_10_EXP__;
1161
1162 static const bool has_infinity = __DBL_HAS_INFINITY__;
1163 static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
1164 static const bool has_signaling_NaN = has_quiet_NaN;
1165 static const float_denorm_style has_denorm
1166 = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1167 static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
1168
1169 static double infinity() throw()
1170 { return __builtin_huge_val(); }
1171 static double quiet_NaN() throw()
1172 { return __builtin_nan (""); }
1173 static double signaling_NaN() throw()
1174 { return __builtin_nans (""); }
1175 static double denorm_min() throw()
1176 { return __DBL_DENORM_MIN__; }
1177
1178 static const bool is_iec559
1179 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1180 static const bool is_bounded = true;
1181 static const bool is_modulo = false;
1182
1183 static const bool traps = __glibcxx_double_traps;
1184 static const bool tinyness_before = __glibcxx_double_tinyness_before;
1185 static const float_round_style round_style = round_to_nearest;
1186 };
1187
1188 #undef __glibcxx_double_has_denorm_loss
1189 #undef __glibcxx_double_traps
1190 #undef __glibcxx_double_tinyness_before
1191
1192 /// numeric_limits<long double> specialization.
1193 template<>
1194 struct numeric_limits<long double>
1195 {
1196 static const bool is_specialized = true;
1197
1198 static long double min() throw()
1199 { return __LDBL_MIN__; }
1200 static long double max() throw()
1201 { return __LDBL_MAX__; }
1202
1203 static const int digits = __LDBL_MANT_DIG__;
1204 static const int digits10 = __LDBL_DIG__;
1205 static const bool is_signed = true;
1206 static const bool is_integer = false;
1207 static const bool is_exact = false;
1208 static const int radix = __FLT_RADIX__;
1209 static long double epsilon() throw()
1210 { return __LDBL_EPSILON__; }
1211 static long double round_error() throw()
1212 { return 0.5L; }
1213
1214 static const int min_exponent = __LDBL_MIN_EXP__;
1215 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
1216 static const int max_exponent = __LDBL_MAX_EXP__;
1217 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
1218
1219 static const bool has_infinity = __LDBL_HAS_INFINITY__;
1220 static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
1221 static const bool has_signaling_NaN = has_quiet_NaN;
1222 static const float_denorm_style has_denorm
1223 = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
1224 static const bool has_denorm_loss
1225 = __glibcxx_long_double_has_denorm_loss;
1226
1227 static long double infinity() throw()
1228 { return __builtin_huge_vall (); }
1229 static long double quiet_NaN() throw()
1230 { return __builtin_nanl (""); }
1231 static long double signaling_NaN() throw()
1232 { return __builtin_nansl (""); }
1233 static long double denorm_min() throw()
1234 { return __LDBL_DENORM_MIN__; }
1235
1236 static const bool is_iec559
1237 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
1238 static const bool is_bounded = true;
1239 static const bool is_modulo = false;
1240
1241 static const bool traps = __glibcxx_long_double_traps;
1242 static const bool tinyness_before = __glibcxx_long_double_tinyness_before;
1243 static const float_round_style round_style = round_to_nearest;
1244 };
1245
1246 #undef __glibcxx_long_double_has_denorm_loss
1247 #undef __glibcxx_long_double_traps
1248 #undef __glibcxx_long_double_tinyness_before
1249
1250 _GLIBCXX_END_NAMESPACE
1251
1252 #undef __glibcxx_signed
1253 #undef __glibcxx_min
1254 #undef __glibcxx_max
1255 #undef __glibcxx_digits
1256 #undef __glibcxx_digits10
1257
1258 #endif // _GLIBCXX_NUMERIC_LIMITS