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