1// The template and inlines for the numeric_limits classes. -*- C++ -*- 2 3// Copyright (C) 1999-2013 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 3, or (at your option) 9// any later version. 10 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. 15 16// Under Section 7 of GPL version 3, you are granted additional 17// permissions described in the GCC Runtime Library Exception, version 18// 3.1, as published by the Free Software Foundation. 19 20// You should have received a copy of the GNU General Public License and 21// a copy of the GCC Runtime Library Exception along with this program; 22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23// <http://www.gnu.org/licenses/>. 24 25/** @file include/limits 26 * This is a Standard C++ Library header. 27 */ 28 29// Note: this is not a conforming implementation. 30// Written by Gabriel Dos Reis <gdr@codesourcery.com> 31 32// 33// ISO 14882:1998 34// 18.2.1 35// 36 37#ifndef _GLIBCXX_NUMERIC_LIMITS 38#define _GLIBCXX_NUMERIC_LIMITS 1 39 40#pragma GCC system_header 41 42#include <float.h> 43#include <limits.h> 44#include <math.h> 45 46 47// 48// The numeric_limits<> traits document implementation-defined aspects 49// of fundamental arithmetic data types (integers and floating points). 50// From Standard C++ point of view, there are 14 such types: 51// * integers 52// bool (1) 53// char, signed char, unsigned char, wchar_t (4) 54// short, unsigned short (2) 55// int, unsigned (2) 56// long, unsigned long (2) 57// 58// * floating points 59// float (1) 60// double (1) 61// long double (1) 62// 63// GNU C++ understands (where supported by the host C-library) 64// * integer 65// long long, unsigned long long (2) 66// 67// which brings us to 16 fundamental arithmetic data types in GNU C++. 68// 69// 70// Since a numeric_limits<> is a bit tricky to get right, we rely on 71// an interface composed of macros which should be defined in config/os 72// or config/cpu when they differ from the generic (read arbitrary) 73// definitions given here. 74// 75 76// These values can be overridden in the target configuration file. 77// The default values are appropriate for many 32-bit targets. 78 79// GCC only intrinsically supports modulo integral types. The only remaining 80// integral exceptional values is division by zero. Only targets that do not 81// signal division by zero in some "hard to ignore" way should use false. 82#ifndef __glibcxx_integral_traps 83# define __glibcxx_integral_traps true 84#endif 85 86// float 87// 88 89// Default values. Should be overridden in configuration files if necessary. 90 91#ifndef __glibcxx_float_has_denorm_loss 92# define __glibcxx_float_has_denorm_loss false 93#endif 94#ifndef __glibcxx_float_traps 95# define __glibcxx_float_traps false 96#endif 97#ifndef __glibcxx_float_tinyness_before 98# define __glibcxx_float_tinyness_before false 99#endif 100 101// double 102 103// Default values. Should be overridden in configuration files if necessary. 104 105#ifndef __glibcxx_double_has_denorm_loss 106# define __glibcxx_double_has_denorm_loss false 107#endif 108#ifndef __glibcxx_double_traps 109# define __glibcxx_double_traps false 110#endif 111#ifndef __glibcxx_double_tinyness_before 112# define __glibcxx_double_tinyness_before false 113#endif 114 115// long double 116 117// Default values. Should be overridden in configuration files if necessary. 118 119#ifndef __glibcxx_long_double_has_denorm_loss 120# define __glibcxx_long_double_has_denorm_loss false 121#endif 122#ifndef __glibcxx_long_double_traps 123# define __glibcxx_long_double_traps false 124#endif 125#ifndef __glibcxx_long_double_tinyness_before 126# define __glibcxx_long_double_tinyness_before false 127#endif 128 129// You should not need to define any macros below this point. 130 131#define __glibcxx_signed(T) ((T)(-1) < 0) 132 133#define __glibcxx_min(T) \ 134 (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0) 135 136#define __glibcxx_max(T) \ 137 (__glibcxx_signed (T) ? \ 138 (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0) 139 140#define __glibcxx_digits(T) \ 141 (sizeof(T) * CHAR_BIT - __glibcxx_signed (T)) 142 143// The fraction 643/2136 approximates log10(2) to 7 significant digits. 144#define __glibcxx_digits10(T) \ 145 (__glibcxx_digits (T) * 643L / 2136) 146 147#define __glibcxx_max_digits10(T) \ 148 (2 + (T) * 643L / 2136) 149 150namespace std 151{ 152 153 /** 154 * @brief Describes the rounding style for floating-point types. 155 * 156 * This is used in the std::numeric_limits class. 157 */ 158 enum float_round_style 159 { 160 round_indeterminate = -1, /// Intermediate. 161 round_toward_zero = 0, /// To zero. 162 round_to_nearest = 1, /// To the nearest representable value. 163 round_toward_infinity = 2, /// To infinity. 164 round_toward_neg_infinity = 3 /// To negative infinity. 165 }; 166 167 /** 168 * @brief Describes the denormalization for floating-point types. 169 * 170 * These values represent the presence or absence of a variable number 171 * of exponent bits. This type is used in the std::numeric_limits class. 172 */ 173 enum float_denorm_style 174 { 175 /// Indeterminate at compile time whether denormalized values are allowed. 176 denorm_indeterminate = -1, 177 /// The type does not allow denormalized values. 178 denorm_absent = 0, 179 /// The type allows denormalized values. 180 denorm_present = 1 181 }; 182 183 /** 184 * @brief Part of std::numeric_limits. 185 * 186 * The @c static @c const members are usable as integral constant 187 * expressions. 188 * 189 * @note This is a separate class for purposes of efficiency; you 190 * should only access these members as part of an instantiation 191 * of the std::numeric_limits class. 192 */ 193 struct __numeric_limits_base 194 { 195 /** This will be true for all fundamental types (which have 196 specializations), and false for everything else. */ 197 static const bool is_specialized = false; 198 199 /** The number of @c radix digits that be represented without change: for 200 integer types, the number of non-sign bits in the mantissa; for 201 floating types, the number of @c radix digits in the mantissa. */ 202 static const int digits = 0; 203 204 /** The number of base 10 digits that can be represented without change. */ 205 static const int digits10 = 0; 206 207#if __cplusplus >= 201103L 208 /** The number of base 10 digits required to ensure that values which 209 differ are always differentiated. */ 210 static constexpr int max_digits10 = 0; 211#endif 212 213 /** True if the type is signed. */ 214 static const bool is_signed = false; 215 216 /** True if the type is integer. */ 217 static const bool is_integer = false; 218 219 /** True if the type uses an exact representation. All integer types are 220 exact, but not all exact types are integer. For example, rational and 221 fixed-exponent representations are exact but not integer. */ 222 static const bool is_exact = false; 223 224 /** For integer types, specifies the base of the representation. For 225 floating types, specifies the base of the exponent representation. */ 226 static const int radix = 0; 227 228 /** The minimum negative integer such that @c radix raised to the power of 229 (one less than that integer) is a normalized floating point number. */ 230 static const int min_exponent = 0; 231 232 /** The minimum negative integer such that 10 raised to that power is in 233 the range of normalized floating point numbers. */ 234 static const int min_exponent10 = 0; 235 236 /** The maximum positive integer such that @c radix raised to the power of 237 (one less than that integer) is a representable finite floating point 238 number. */ 239 static const int max_exponent = 0; 240 241 /** The maximum positive integer such that 10 raised to that power is in 242 the range of representable finite floating point numbers. */ 243 static const int max_exponent10 = 0; 244 245 /** True if the type has a representation for positive infinity. */ 246 static const bool has_infinity = false; 247 248 /** True if the type has a representation for a quiet (non-signaling) 249 Not a Number. */ 250 static const bool has_quiet_NaN = false; 251 252 /** True if the type has a representation for a signaling 253 Not a Number. */ 254 static const bool has_signaling_NaN = false; 255 256 /** See std::float_denorm_style for more information. */ 257 static const float_denorm_style has_denorm = denorm_absent; 258 259 /** True if loss of accuracy is detected as a denormalization loss, 260 rather than as an inexact result. */ 261 static const bool has_denorm_loss = false; 262 263 /** True if-and-only-if the type adheres to the IEC 559 standard, also 264 known as IEEE 754. (Only makes sense for floating point types.) */ 265 static const bool is_iec559 = false; 266 267 /** True if the set of values representable by the type is 268 finite. All built-in types are bounded, this member would be 269 false for arbitrary precision types. */ 270 static const bool is_bounded = false; 271 272 /** True if the type is @e modulo. A type is modulo if, for any 273 operation involving +, -, or * on values of that type whose 274 result would fall outside the range [min(),max()], the value 275 returned differs from the true value by an integer multiple of 276 max() - min() + 1. On most machines, this is false for floating 277 types, true for unsigned integers, and true for signed integers. 278 See PR22200 about signed integers. */ 279 static const bool is_modulo = false; 280 281 /** True if trapping is implemented for this type. */ 282 static const bool traps = false; 283 284 /** True if tininess is detected before rounding. (see IEC 559) */ 285 static const bool tinyness_before = false; 286 287 /** See std::float_round_style for more information. This is only 288 meaningful for floating types; integer types will all be 289 round_toward_zero. */ 290 static const float_round_style round_style = 291 round_toward_zero; 292 }; 293 294 /** 295 * @brief Properties of fundamental types. 296 * 297 * This class allows a program to obtain information about the 298 * representation of a fundamental type on a given platform. For 299 * non-fundamental types, the functions will return 0 and the data 300 * members will all be @c false. 301 * 302 * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are 303 * noted, but not incorporated in this documented (yet). 304 */ 305 template<typename _Tp> 306 struct numeric_limits : public __numeric_limits_base 307 { 308 /** The minimum finite value, or for floating types with 309 denormalization, the minimum positive normalized value. */ 310 static const _Tp 311 min() { return _Tp(); } 312 313 /** The maximum finite value. */ 314 static const _Tp 315 max() { return _Tp(); } 316 317#if __cplusplus >= 201103L 318 /** A finite value x such that there is no other finite value y 319 * where y < x. */ 320 static constexpr _Tp 321 lowest() noexcept { return _Tp(); } 322#endif 323 324 /** The @e machine @e epsilon: the difference between 1 and the least 325 value greater than 1 that is representable. */ 326 static const _Tp 327 epsilon() { return _Tp(); } 328 329 /** The maximum rounding error measurement (see LIA-1). */ 330 static const _Tp 331 round_error() { return _Tp(); } 332 333 /** The representation of positive infinity, if @c has_infinity. */ 334 static const _Tp 335 infinity() { return _Tp(); } 336 337 /** The representation of a quiet Not a Number, 338 if @c has_quiet_NaN. */ 339 static const _Tp 340 quiet_NaN() { return _Tp(); } 341 342 /** The representation of a signaling Not a Number, if 343 @c has_signaling_NaN. */ 344 static const _Tp 345 signaling_NaN() { return _Tp(); } 346 347 /** The minimum positive denormalized value. For types where 348 @c has_denorm is false, this is the minimum positive normalized 349 value. */ 350 static const _Tp 351 denorm_min() { return _Tp(); } 352 }; 353 354#if __cplusplus >= 201103L 355 template<typename _Tp> 356 struct numeric_limits<const _Tp> 357 : public numeric_limits<_Tp> { }; 358 359 template<typename _Tp> 360 struct numeric_limits<volatile _Tp> 361 : public numeric_limits<_Tp> { }; 362 363 template<typename _Tp> 364 struct numeric_limits<const volatile _Tp> 365 : public numeric_limits<_Tp> { }; 366#endif 367 368 // Now there follow 16 explicit specializations. Yes, 16. Make sure 369 // you get the count right. (18 in c++0x mode) 370 371 /// numeric_limits<bool> specialization. 372 template<> 373 struct numeric_limits<bool> 374 { 375 static const bool is_specialized = true; 376 377 static const bool 378 min() { return false; } 379 380 static const bool 381 max() { return true; } 382 383#if __cplusplus >= 201103L 384 static constexpr bool 385 lowest() noexcept { return min(); } 386#endif 387 static const int digits = 1; 388 static const int digits10 = 0; 389#if __cplusplus >= 201103L 390 static constexpr int max_digits10 = 0; 391#endif 392 static const bool is_signed = false; 393 static const bool is_integer = true; 394 static const bool is_exact = true; 395 static const int radix = 2; 396 397 static const bool 398 epsilon() { return false; } 399 400 static const bool 401 round_error() { return false; } 402 403 static const int min_exponent = 0; 404 static const int min_exponent10 = 0; 405 static const int max_exponent = 0; 406 static const int max_exponent10 = 0; 407 408 static const bool has_infinity = false; 409 static const bool has_quiet_NaN = false; 410 static const bool has_signaling_NaN = false; 411 static const float_denorm_style has_denorm 412 = denorm_absent; 413 static const bool has_denorm_loss = false; 414 415 static const bool 416 infinity() { return false; } 417 418 static const bool 419 quiet_NaN() { return false; } 420 421 static const bool 422 signaling_NaN() { return false; } 423 424 static const bool 425 denorm_min() { return false; } 426 427 static const bool is_iec559 = false; 428 static const bool is_bounded = true; 429 static const bool is_modulo = false; 430 431 // It is not clear what it means for a boolean type to trap. 432 // This is a DR on the LWG issue list. Here, I use integer 433 // promotion semantics. 434 static const bool traps = __glibcxx_integral_traps; 435 static const bool tinyness_before = false; 436 static const float_round_style round_style 437 = round_toward_zero; 438 }; 439 440 /// numeric_limits<char> specialization. 441 template<> 442 struct numeric_limits<char> 443 { 444 static const bool is_specialized = true; 445 446 static const char 447 min() { return __glibcxx_min(char); } 448 449 static const char 450 max() { return __glibcxx_max(char); } 451 452#if __cplusplus >= 201103L 453 static constexpr char 454 lowest() noexcept { return min(); } 455#endif 456 457 static const int digits = __glibcxx_digits (char); 458 static const int digits10 = __glibcxx_digits10 (char); 459#if __cplusplus >= 201103L 460 static constexpr int max_digits10 = 0; 461#endif 462 static const bool is_signed = __glibcxx_signed (char); 463 static const bool is_integer = true; 464 static const bool is_exact = true; 465 static const int radix = 2; 466 467 static const char 468 epsilon() { return 0; } 469 470 static const char 471 round_error() { return 0; } 472 473 static const int min_exponent = 0; 474 static const int min_exponent10 = 0; 475 static const int max_exponent = 0; 476 static const int max_exponent10 = 0; 477 478 static const bool has_infinity = false; 479 static const bool has_quiet_NaN = false; 480 static const bool has_signaling_NaN = false; 481 static const float_denorm_style has_denorm 482 = denorm_absent; 483 static const bool has_denorm_loss = false; 484 485 static const 486 char infinity() { return char(); } 487 488 static const char 489 quiet_NaN() { return char(); } 490 491 static const char 492 signaling_NaN() { return char(); } 493 494 static const char 495 denorm_min() { return static_cast<char>(0); } 496 497 static const bool is_iec559 = false; 498 static const bool is_bounded = true; 499 static const bool is_modulo = !is_signed; 500 501 static const bool traps = __glibcxx_integral_traps; 502 static const bool tinyness_before = false; 503 static const float_round_style round_style 504 = round_toward_zero; 505 }; 506 507 /// numeric_limits<signed char> specialization. 508 template<> 509 struct numeric_limits<signed char> 510 { 511 static const bool is_specialized = true; 512 513 static const signed char 514 min() { return -SCHAR_MAX - 1; } 515 516 static const signed char 517 max() { return SCHAR_MAX; } 518 519#if __cplusplus >= 201103L 520 static constexpr signed char 521 lowest() noexcept { return min(); } 522#endif 523 524 static const int digits = __glibcxx_digits (signed char); 525 static const int digits10 526 = __glibcxx_digits10 (signed char); 527#if __cplusplus >= 201103L 528 static constexpr int max_digits10 = 0; 529#endif 530 static const bool is_signed = true; 531 static const bool is_integer = true; 532 static const bool is_exact = true; 533 static const int radix = 2; 534 535 static const signed char 536 epsilon() { return 0; } 537 538 static const signed char 539 round_error() { return 0; } 540 541 static const int min_exponent = 0; 542 static const int min_exponent10 = 0; 543 static const int max_exponent = 0; 544 static const int max_exponent10 = 0; 545 546 static const bool has_infinity = false; 547 static const bool has_quiet_NaN = false; 548 static const bool has_signaling_NaN = false; 549 static const float_denorm_style has_denorm 550 = denorm_absent; 551 static const bool has_denorm_loss = false; 552 553 static const signed char 554 infinity() { return static_cast<signed char>(0); } 555 556 static const signed char 557 quiet_NaN() { return static_cast<signed char>(0); } 558 559 static const signed char 560 signaling_NaN() 561 { return static_cast<signed char>(0); } 562 563 static const signed char 564 denorm_min() 565 { return static_cast<signed char>(0); } 566 567 static const bool is_iec559 = false; 568 static const bool is_bounded = true; 569 static const bool is_modulo = false; 570 571 static const bool traps = __glibcxx_integral_traps; 572 static const bool tinyness_before = false; 573 static const float_round_style round_style 574 = round_toward_zero; 575 }; 576 577 /// numeric_limits<unsigned char> specialization. 578 template<> 579 struct numeric_limits<unsigned char> 580 { 581 static const bool is_specialized = true; 582 583 static const unsigned char 584 min() { return 0; } 585 586 static const unsigned char 587 max() { return SCHAR_MAX * 2U + 1; } 588 589#if __cplusplus >= 201103L 590 static constexpr unsigned char 591 lowest() noexcept { return min(); } 592#endif 593 594 static const int digits 595 = __glibcxx_digits (unsigned char); 596 static const int digits10 597 = __glibcxx_digits10 (unsigned char); 598#if __cplusplus >= 201103L 599 static constexpr int max_digits10 = 0; 600#endif 601 static const bool is_signed = false; 602 static const bool is_integer = true; 603 static const bool is_exact = true; 604 static const int radix = 2; 605 606 static const unsigned char 607 epsilon() { return 0; } 608 609 static const unsigned char 610 round_error() { return 0; } 611 612 static const int min_exponent = 0; 613 static const int min_exponent10 = 0; 614 static const int max_exponent = 0; 615 static const int max_exponent10 = 0; 616 617 static const bool has_infinity = false; 618 static const bool has_quiet_NaN = false; 619 static const bool has_signaling_NaN = false; 620 static const float_denorm_style has_denorm 621 = denorm_absent; 622 static const bool has_denorm_loss = false; 623 624 static const unsigned char 625 infinity() 626 { return static_cast<unsigned char>(0); } 627 628 static const unsigned char 629 quiet_NaN() 630 { return static_cast<unsigned char>(0); } 631 632 static const unsigned char 633 signaling_NaN() 634 { return static_cast<unsigned char>(0); } 635 636 static const unsigned char 637 denorm_min() 638 { return static_cast<unsigned char>(0); } 639 640 static const bool is_iec559 = false; 641 static const bool is_bounded = true; 642 static const bool is_modulo = true; 643 644 static const bool traps = __glibcxx_integral_traps; 645 static const bool tinyness_before = false; 646 static const float_round_style round_style 647 = round_toward_zero; 648 }; 649 650 /// numeric_limits<wchar_t> specialization. 651 template<> 652 struct numeric_limits<wchar_t> 653 { 654 static const bool is_specialized = true; 655 656 static const wchar_t 657 min() { return __glibcxx_min (wchar_t); } 658 659 static const wchar_t 660 max() { return __glibcxx_max (wchar_t); } 661 662#if __cplusplus >= 201103L 663 static constexpr wchar_t 664 lowest() noexcept { return min(); } 665#endif 666 667 static const int digits = __glibcxx_digits (wchar_t); 668 static const int digits10 669 = __glibcxx_digits10 (wchar_t); 670#if __cplusplus >= 201103L 671 static constexpr int max_digits10 = 0; 672#endif 673 static const bool is_signed = __glibcxx_signed (wchar_t); 674 static const bool is_integer = true; 675 static const bool is_exact = true; 676 static const int radix = 2; 677 678 static const wchar_t 679 epsilon() { return 0; } 680 681 static const wchar_t 682 round_error() { return 0; } 683 684 static const int min_exponent = 0; 685 static const int min_exponent10 = 0; 686 static const int max_exponent = 0; 687 static const int max_exponent10 = 0; 688 689 static const bool has_infinity = false; 690 static const bool has_quiet_NaN = false; 691 static const bool has_signaling_NaN = false; 692 static const float_denorm_style has_denorm 693 = denorm_absent; 694 static const bool has_denorm_loss = false; 695 696 static const wchar_t 697 infinity() { return wchar_t(); } 698 699 static const wchar_t 700 quiet_NaN() { return wchar_t(); } 701 702 static const wchar_t 703 signaling_NaN() { return wchar_t(); } 704 705 static const wchar_t 706 denorm_min() { return wchar_t(); } 707 708 static const bool is_iec559 = false; 709 static const bool is_bounded = true; 710 static const bool is_modulo = !is_signed; 711 712 static const bool traps = __glibcxx_integral_traps; 713 static const bool tinyness_before = false; 714 static const float_round_style round_style 715 = round_toward_zero; 716 }; 717 718#if __cplusplus >= 201103L 719 /// numeric_limits<char16_t> specialization. 720 template<> 721 struct numeric_limits<char16_t> 722 { 723 static constexpr bool is_specialized = true; 724 725 static constexpr char16_t 726 min() noexcept { return __glibcxx_min (char16_t); } 727 728 static constexpr char16_t 729 max() noexcept { return __glibcxx_max (char16_t); } 730 731 static constexpr char16_t 732 lowest() noexcept { return min(); } 733 734 static constexpr int digits = __glibcxx_digits (char16_t); 735 static constexpr int digits10 = __glibcxx_digits10 (char16_t); 736 static constexpr int max_digits10 = 0; 737 static constexpr bool is_signed = __glibcxx_signed (char16_t); 738 static constexpr bool is_integer = true; 739 static constexpr bool is_exact = true; 740 static constexpr int radix = 2; 741 742 static constexpr char16_t 743 epsilon() noexcept { return 0; } 744 745 static constexpr char16_t 746 round_error() noexcept { return 0; } 747 748 static constexpr int min_exponent = 0; 749 static constexpr int min_exponent10 = 0; 750 static constexpr int max_exponent = 0; 751 static constexpr int max_exponent10 = 0; 752 753 static constexpr bool has_infinity = false; 754 static constexpr bool has_quiet_NaN = false; 755 static constexpr bool has_signaling_NaN = false; 756 static constexpr float_denorm_style has_denorm = denorm_absent; 757 static constexpr bool has_denorm_loss = false; 758 759 static constexpr char16_t 760 infinity() noexcept { return char16_t(); } 761 762 static constexpr char16_t 763 quiet_NaN() noexcept { return char16_t(); } 764 765 static constexpr char16_t 766 signaling_NaN() noexcept { return char16_t(); } 767 768 static constexpr char16_t 769 denorm_min() noexcept { return char16_t(); } 770 771 static constexpr bool is_iec559 = false; 772 static constexpr bool is_bounded = true; 773 static constexpr bool is_modulo = !is_signed; 774 775 static constexpr bool traps = __glibcxx_integral_traps; 776 static constexpr bool tinyness_before = false; 777 static constexpr float_round_style round_style = round_toward_zero; 778 }; 779 780 /// numeric_limits<char32_t> specialization. 781 template<> 782 struct numeric_limits<char32_t> 783 { 784 static constexpr bool is_specialized = true; 785 786 static constexpr char32_t 787 min() noexcept { return __glibcxx_min (char32_t); } 788 789 static constexpr char32_t 790 max() noexcept { return __glibcxx_max (char32_t); } 791 792 static constexpr char32_t 793 lowest() noexcept { return min(); } 794 795 static constexpr int digits = __glibcxx_digits (char32_t); 796 static constexpr int digits10 = __glibcxx_digits10 (char32_t); 797 static constexpr int max_digits10 = 0; 798 static constexpr bool is_signed = __glibcxx_signed (char32_t); 799 static constexpr bool is_integer = true; 800 static constexpr bool is_exact = true; 801 static constexpr int radix = 2; 802 803 static constexpr char32_t 804 epsilon() noexcept { return 0; } 805 806 static constexpr char32_t 807 round_error() noexcept { return 0; } 808 809 static constexpr int min_exponent = 0; 810 static constexpr int min_exponent10 = 0; 811 static constexpr int max_exponent = 0; 812 static constexpr int max_exponent10 = 0; 813 814 static constexpr bool has_infinity = false; 815 static constexpr bool has_quiet_NaN = false; 816 static constexpr bool has_signaling_NaN = false; 817 static constexpr float_denorm_style has_denorm = denorm_absent; 818 static constexpr bool has_denorm_loss = false; 819 820 static constexpr char32_t 821 infinity() noexcept { return char32_t(); } 822 823 static constexpr char32_t 824 quiet_NaN() noexcept { return char32_t(); } 825 826 static constexpr char32_t 827 signaling_NaN() noexcept { return char32_t(); } 828 829 static constexpr char32_t 830 denorm_min() noexcept { return char32_t(); } 831 832 static constexpr bool is_iec559 = false; 833 static constexpr bool is_bounded = true; 834 static constexpr bool is_modulo = !is_signed; 835 836 static constexpr bool traps = __glibcxx_integral_traps; 837 static constexpr bool tinyness_before = false; 838 static constexpr float_round_style round_style = round_toward_zero; 839 }; 840#endif 841 842 /// numeric_limits<short> specialization. 843 template<> 844 struct numeric_limits<short> 845 { 846 static const bool is_specialized = true; 847 848 static const short 849 min() { return -SHRT_MAX - 1; } 850 851 static const short 852 max() { return SHRT_MAX; } 853 854#if __cplusplus >= 201103L 855 static constexpr short 856 lowest() noexcept { return min(); } 857#endif 858 859 static const int digits = __glibcxx_digits (short); 860 static const int digits10 = __glibcxx_digits10 (short); 861#if __cplusplus >= 201103L 862 static constexpr int max_digits10 = 0; 863#endif 864 static const bool is_signed = true; 865 static const bool is_integer = true; 866 static const bool is_exact = true; 867 static const int radix = 2; 868 869 static const short 870 epsilon() { return 0; } 871 872 static const short 873 round_error() { return 0; } 874 875 static const int min_exponent = 0; 876 static const int min_exponent10 = 0; 877 static const int max_exponent = 0; 878 static const int max_exponent10 = 0; 879 880 static const bool has_infinity = false; 881 static const bool has_quiet_NaN = false; 882 static const bool has_signaling_NaN = false; 883 static const float_denorm_style has_denorm 884 = denorm_absent; 885 static const bool has_denorm_loss = false; 886 887 static const short 888 infinity() { return short(); } 889 890 static const short 891 quiet_NaN() { return short(); } 892 893 static const short 894 signaling_NaN() { return short(); } 895 896 static const short 897 denorm_min() { return short(); } 898 899 static const bool is_iec559 = false; 900 static const bool is_bounded = true; 901 static const bool is_modulo = false; 902 903 static const bool traps = __glibcxx_integral_traps; 904 static const bool tinyness_before = false; 905 static const float_round_style round_style 906 = round_toward_zero; 907 }; 908 909 /// numeric_limits<unsigned short> specialization. 910 template<> 911 struct numeric_limits<unsigned short> 912 { 913 static const bool is_specialized = true; 914 915 static const unsigned short 916 min() { return 0; } 917 918 static const unsigned short 919 max() { return SHRT_MAX * 2U + 1; } 920 921#if __cplusplus >= 201103L 922 static constexpr unsigned short 923 lowest() noexcept { return min(); } 924#endif 925 926 static const int digits 927 = __glibcxx_digits (unsigned short); 928 static const int digits10 929 = __glibcxx_digits10 (unsigned short); 930#if __cplusplus >= 201103L 931 static constexpr int max_digits10 = 0; 932#endif 933 static const bool is_signed = false; 934 static const bool is_integer = true; 935 static const bool is_exact = true; 936 static const int radix = 2; 937 938 static const unsigned short 939 epsilon() { return 0; } 940 941 static const unsigned short 942 round_error() { return 0; } 943 944 static const int min_exponent = 0; 945 static const int min_exponent10 = 0; 946 static const int max_exponent = 0; 947 static const int max_exponent10 = 0; 948 949 static const bool has_infinity = false; 950 static const bool has_quiet_NaN = false; 951 static const bool has_signaling_NaN = false; 952 static const float_denorm_style has_denorm 953 = denorm_absent; 954 static const bool has_denorm_loss = false; 955 956 static const unsigned short 957 infinity() 958 { return static_cast<unsigned short>(0); } 959 960 static const unsigned short 961 quiet_NaN() 962 { return static_cast<unsigned short>(0); } 963 964 static const unsigned short 965 signaling_NaN() 966 { return static_cast<unsigned short>(0); } 967 968 static const unsigned short 969 denorm_min() 970 { return static_cast<unsigned short>(0); } 971 972 static const bool is_iec559 = false; 973 static const bool is_bounded = true; 974 static const bool is_modulo = true; 975 976 static const bool traps = __glibcxx_integral_traps; 977 static const bool tinyness_before = false; 978 static const float_round_style round_style 979 = round_toward_zero; 980 }; 981 982 /// numeric_limits<int> specialization. 983 template<> 984 struct numeric_limits<int> 985 { 986 static const bool is_specialized = true; 987 988 static const int 989 min() { return -__INT_MAX__ - 1; } 990 991 static const int 992 max() { return __INT_MAX__; } 993 994#if __cplusplus >= 201103L 995 static constexpr int 996 lowest() noexcept { return min(); } 997#endif 998 999 static const int digits = __glibcxx_digits (int); 1000 static const int digits10 = __glibcxx_digits10 (int); 1001#if __cplusplus >= 201103L 1002 static constexpr int max_digits10 = 0; 1003#endif 1004 static const bool is_signed = true; 1005 static const bool is_integer = true; 1006 static const bool is_exact = true; 1007 static const int radix = 2; 1008 1009 static const int 1010 epsilon() { return 0; } 1011 1012 static const int 1013 round_error() { return 0; } 1014 1015 static const int min_exponent = 0; 1016 static const int min_exponent10 = 0; 1017 static const int max_exponent = 0; 1018 static const int max_exponent10 = 0; 1019 1020 static const bool has_infinity = false; 1021 static const bool has_quiet_NaN = false; 1022 static const bool has_signaling_NaN = false; 1023 static const float_denorm_style has_denorm 1024 = denorm_absent; 1025 static const bool has_denorm_loss = false; 1026 1027 static const int 1028 infinity() { return static_cast<int>(0); } 1029 1030 static const int 1031 quiet_NaN() { return static_cast<int>(0); } 1032 1033 static const int 1034 signaling_NaN() { return static_cast<int>(0); } 1035 1036 static const int 1037 denorm_min() { return static_cast<int>(0); } 1038 1039 static const bool is_iec559 = false; 1040 static const bool is_bounded = true; 1041 static const bool is_modulo = false; 1042 1043 static const bool traps = __glibcxx_integral_traps; 1044 static const bool tinyness_before = false; 1045 static const float_round_style round_style 1046 = round_toward_zero; 1047 }; 1048 1049 /// numeric_limits<unsigned int> specialization. 1050 template<> 1051 struct numeric_limits<unsigned int> 1052 { 1053 static const bool is_specialized = true; 1054 1055 static const unsigned int 1056 min() { return 0; } 1057 1058 static const unsigned int 1059 max() { return __INT_MAX__ * 2U + 1; } 1060 1061#if __cplusplus >= 201103L 1062 static constexpr unsigned int 1063 lowest() noexcept { return min(); } 1064#endif 1065 1066 static const int digits 1067 = __glibcxx_digits (unsigned int); 1068 static const int digits10 1069 = __glibcxx_digits10 (unsigned int); 1070#if __cplusplus >= 201103L 1071 static constexpr int max_digits10 = 0; 1072#endif 1073 static const bool is_signed = false; 1074 static const bool is_integer = true; 1075 static const bool is_exact = true; 1076 static const int radix = 2; 1077 1078 static const unsigned int 1079 epsilon() { return 0; } 1080 1081 static const unsigned int 1082 round_error() { return 0; } 1083 1084 static const int min_exponent = 0; 1085 static const int min_exponent10 = 0; 1086 static const int max_exponent = 0; 1087 static const int max_exponent10 = 0; 1088 1089 static const bool has_infinity = false; 1090 static const bool has_quiet_NaN = false; 1091 static const bool has_signaling_NaN = false; 1092 static const float_denorm_style has_denorm 1093 = denorm_absent; 1094 static const bool has_denorm_loss = false; 1095 1096 static const unsigned int 1097 infinity() { return static_cast<unsigned int>(0); } 1098 1099 static const unsigned int 1100 quiet_NaN() 1101 { return static_cast<unsigned int>(0); } 1102 1103 static const unsigned int 1104 signaling_NaN() 1105 { return static_cast<unsigned int>(0); } 1106 1107 static const unsigned int 1108 denorm_min() 1109 { return static_cast<unsigned int>(0); } 1110 1111 static const bool is_iec559 = false; 1112 static const bool is_bounded = true; 1113 static const bool is_modulo = true; 1114 1115 static const bool traps = __glibcxx_integral_traps; 1116 static const bool tinyness_before = false; 1117 static const float_round_style round_style 1118 = round_toward_zero; 1119 }; 1120 1121 /// numeric_limits<long> specialization. 1122 template<> 1123 struct numeric_limits<long> 1124 { 1125 static const bool is_specialized = true; 1126 1127 static const long 1128 min() { return -__LONG_MAX__ - 1; } 1129 1130 static const long 1131 max() { return __LONG_MAX__; } 1132 1133#if __cplusplus >= 201103L 1134 static constexpr long 1135 lowest() noexcept { return min(); } 1136#endif 1137 1138 static const int digits = __glibcxx_digits (long); 1139 static const int digits10 = __glibcxx_digits10 (long); 1140#if __cplusplus >= 201103L 1141 static constexpr int max_digits10 = 0; 1142#endif 1143 static const bool is_signed = true; 1144 static const bool is_integer = true; 1145 static const bool is_exact = true; 1146 static const int radix = 2; 1147 1148 static const long 1149 epsilon() { return 0; } 1150 1151 static const long 1152 round_error() { return 0; } 1153 1154 static const int min_exponent = 0; 1155 static const int min_exponent10 = 0; 1156 static const int max_exponent = 0; 1157 static const int max_exponent10 = 0; 1158 1159 static const bool has_infinity = false; 1160 static const bool has_quiet_NaN = false; 1161 static const bool has_signaling_NaN = false; 1162 static const float_denorm_style has_denorm 1163 = denorm_absent; 1164 static const bool has_denorm_loss = false; 1165 1166 static const long 1167 infinity() { return static_cast<long>(0); } 1168 1169 static const long 1170 quiet_NaN() { return static_cast<long>(0); } 1171 1172 static const long 1173 signaling_NaN() { return static_cast<long>(0); } 1174 1175 static const long 1176 denorm_min() { return static_cast<long>(0); } 1177 1178 static const bool is_iec559 = false; 1179 static const bool is_bounded = true; 1180 static const bool is_modulo = false; 1181 1182 static const bool traps = __glibcxx_integral_traps; 1183 static const bool tinyness_before = false; 1184 static const float_round_style round_style 1185 = round_toward_zero; 1186 }; 1187 1188 /// numeric_limits<unsigned long> specialization. 1189 template<> 1190 struct numeric_limits<unsigned long> 1191 { 1192 static const bool is_specialized = true; 1193 1194 static const unsigned long 1195 min() { return 0; } 1196 1197 static const unsigned long 1198 max() { return __LONG_MAX__ * 2UL + 1; } 1199 1200#if __cplusplus >= 201103L 1201 static constexpr unsigned long 1202 lowest() noexcept { return min(); } 1203#endif 1204 1205 static const int digits 1206 = __glibcxx_digits (unsigned long); 1207 static const int digits10 1208 = __glibcxx_digits10 (unsigned long); 1209#if __cplusplus >= 201103L 1210 static constexpr int max_digits10 = 0; 1211#endif 1212 static const bool is_signed = false; 1213 static const bool is_integer = true; 1214 static const bool is_exact = true; 1215 static const int radix = 2; 1216 1217 static const unsigned long 1218 epsilon() { return 0; } 1219 1220 static const unsigned long 1221 round_error() { return 0; } 1222 1223 static const int min_exponent = 0; 1224 static const int min_exponent10 = 0; 1225 static const int max_exponent = 0; 1226 static const int max_exponent10 = 0; 1227 1228 static const bool has_infinity = false; 1229 static const bool has_quiet_NaN = false; 1230 static const bool has_signaling_NaN = false; 1231 static const float_denorm_style has_denorm 1232 = denorm_absent; 1233 static const bool has_denorm_loss = false; 1234 1235 static const unsigned long 1236 infinity() 1237 { return static_cast<unsigned long>(0); } 1238 1239 static const unsigned long 1240 quiet_NaN() 1241 { return static_cast<unsigned long>(0); } 1242 1243 static const unsigned long 1244 signaling_NaN() 1245 { return static_cast<unsigned long>(0); } 1246 1247 static const unsigned long 1248 denorm_min() 1249 { return static_cast<unsigned long>(0); } 1250 1251 static const bool is_iec559 = false; 1252 static const bool is_bounded = true; 1253 static const bool is_modulo = true; 1254 1255 static const bool traps = __glibcxx_integral_traps; 1256 static const bool tinyness_before = false; 1257 static const float_round_style round_style 1258 = round_toward_zero; 1259 }; 1260 1261 /// numeric_limits<long long> specialization. 1262 template<> 1263 struct numeric_limits<long long> 1264 { 1265 static const bool is_specialized = true; 1266 1267 static const long long 1268 min() { return -__LONG_LONG_MAX__ - 1; } 1269 1270 static const long long 1271 max() { return __LONG_LONG_MAX__; } 1272 1273#if __cplusplus >= 201103L 1274 static constexpr long long 1275 lowest() noexcept { return min(); } 1276#endif 1277 1278 static const int digits 1279 = __glibcxx_digits (long long); 1280 static const int digits10 1281 = __glibcxx_digits10 (long long); 1282#if __cplusplus >= 201103L 1283 static constexpr int max_digits10 = 0; 1284#endif 1285 static const bool is_signed = true; 1286 static const bool is_integer = true; 1287 static const bool is_exact = true; 1288 static const int radix = 2; 1289 1290 static const long long 1291 epsilon() { return 0; } 1292 1293 static const long long 1294 round_error() { return 0; } 1295 1296 static const int min_exponent = 0; 1297 static const int min_exponent10 = 0; 1298 static const int max_exponent = 0; 1299 static const int max_exponent10 = 0; 1300 1301 static const bool has_infinity = false; 1302 static const bool has_quiet_NaN = false; 1303 static const bool has_signaling_NaN = false; 1304 static const float_denorm_style has_denorm 1305 = denorm_absent; 1306 static const bool has_denorm_loss = false; 1307 1308 static const long long 1309 infinity() { return static_cast<long long>(0); } 1310 1311 static const long long 1312 quiet_NaN() { return static_cast<long long>(0); } 1313 1314 static const long long 1315 signaling_NaN() 1316 { return static_cast<long long>(0); } 1317 1318 static const long long 1319 denorm_min() { return static_cast<long long>(0); } 1320 1321 static const bool is_iec559 = false; 1322 static const bool is_bounded = true; 1323 static const bool is_modulo = false; 1324 1325 static const bool traps = __glibcxx_integral_traps; 1326 static const bool tinyness_before = false; 1327 static const float_round_style round_style 1328 = round_toward_zero; 1329 }; 1330 1331 /// numeric_limits<unsigned long long> specialization. 1332 template<> 1333 struct numeric_limits<unsigned long long> 1334 { 1335 static const bool is_specialized = true; 1336 1337 static const unsigned long long 1338 min() { return 0; } 1339 1340 static const unsigned long long 1341 max() { return __LONG_LONG_MAX__ * 2ULL + 1; } 1342 1343#if __cplusplus >= 201103L 1344 static constexpr unsigned long long 1345 lowest() noexcept { return min(); } 1346#endif 1347 1348 static const int digits 1349 = __glibcxx_digits (unsigned long long); 1350 static const int digits10 1351 = __glibcxx_digits10 (unsigned long long); 1352#if __cplusplus >= 201103L 1353 static constexpr int max_digits10 = 0; 1354#endif 1355 static const bool is_signed = false; 1356 static const bool is_integer = true; 1357 static const bool is_exact = true; 1358 static const int radix = 2; 1359 1360 static const unsigned long long 1361 epsilon() { return 0; } 1362 1363 static const unsigned long long 1364 round_error() { return 0; } 1365 1366 static const int min_exponent = 0; 1367 static const int min_exponent10 = 0; 1368 static const int max_exponent = 0; 1369 static const int max_exponent10 = 0; 1370 1371 static const bool has_infinity = false; 1372 static const bool has_quiet_NaN = false; 1373 static const bool has_signaling_NaN = false; 1374 static const float_denorm_style has_denorm 1375 = denorm_absent; 1376 static const bool has_denorm_loss = false; 1377 1378 static const unsigned long long 1379 infinity() 1380 { return static_cast<unsigned long long>(0); } 1381 1382 static const unsigned long long 1383 quiet_NaN() 1384 { return static_cast<unsigned long long>(0); } 1385 1386 static const unsigned long long 1387 signaling_NaN() 1388 { return static_cast<unsigned long long>(0); } 1389 1390 static const unsigned long long 1391 denorm_min() 1392 { return static_cast<unsigned long long>(0); } 1393 1394 static const bool is_iec559 = false; 1395 static const bool is_bounded = true; 1396 static const bool is_modulo = true; 1397 1398 static const bool traps = __glibcxx_integral_traps; 1399 static const bool tinyness_before = false; 1400 static const float_round_style round_style 1401 = round_toward_zero; 1402 }; 1403 1404#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) 1405 /// numeric_limits<__int128> specialization. 1406 template<> 1407 struct numeric_limits<__int128> 1408 { 1409 static const bool is_specialized = true; 1410 1411 static const __int128 1412 min() { return __glibcxx_min (__int128); } 1413 1414 static const __int128 1415 max() { return __glibcxx_max (__int128); } 1416 1417#if __cplusplus >= 201103L 1418 static constexpr __int128 1419 lowest() noexcept { return min(); } 1420#endif 1421 1422 static const int digits 1423 = __glibcxx_digits (__int128); 1424 static const int digits10 1425 = __glibcxx_digits10 (__int128); 1426#if __cplusplus >= 201103L 1427 static constexpr int max_digits10 = 0; 1428#endif 1429 static const bool is_signed = true; 1430 static const bool is_integer = true; 1431 static const bool is_exact = true; 1432 static const int radix = 2; 1433 1434 static const __int128 1435 epsilon() { return 0; } 1436 1437 static const __int128 1438 round_error() { return 0; } 1439 1440 static const int min_exponent = 0; 1441 static const int min_exponent10 = 0; 1442 static const int max_exponent = 0; 1443 static const int max_exponent10 = 0; 1444 1445 static const bool has_infinity = false; 1446 static const bool has_quiet_NaN = false; 1447 static const bool has_signaling_NaN = false; 1448 static const float_denorm_style has_denorm 1449 = denorm_absent; 1450 static const bool has_denorm_loss = false; 1451 1452 static const __int128 1453 infinity() 1454 { return static_cast<__int128>(0); } 1455 1456 static const __int128 1457 quiet_NaN() 1458 { return static_cast<__int128>(0); } 1459 1460 static const __int128 1461 signaling_NaN() 1462 { return static_cast<__int128>(0); } 1463 1464 static const __int128 1465 denorm_min() 1466 { return static_cast<__int128>(0); } 1467 1468 static const bool is_iec559 = false; 1469 static const bool is_bounded = true; 1470 static const bool is_modulo = false; 1471 1472 static const bool traps 1473 = __glibcxx_integral_traps; 1474 static const bool tinyness_before = false; 1475 static const float_round_style round_style 1476 = round_toward_zero; 1477 }; 1478 1479 /// numeric_limits<unsigned __int128> specialization. 1480 template<> 1481 struct numeric_limits<unsigned __int128> 1482 { 1483 static const bool is_specialized = true; 1484 1485 static const unsigned __int128 1486 min() { return 0; } 1487 1488 static const unsigned __int128 1489 max() { return __glibcxx_max (unsigned __int128); } 1490 1491#if __cplusplus >= 201103L 1492 static constexpr unsigned __int128 1493 lowest() noexcept { return min(); } 1494#endif 1495 1496 static const int digits 1497 = __glibcxx_digits (unsigned __int128); 1498 static const int digits10 1499 = __glibcxx_digits10 (unsigned __int128); 1500#if __cplusplus >= 201103L 1501 static constexpr int max_digits10 = 0; 1502#endif 1503 static const bool is_signed = false; 1504 static const bool is_integer = true; 1505 static const bool is_exact = true; 1506 static const int radix = 2; 1507 1508 static const unsigned __int128 1509 epsilon() { return 0; } 1510 1511 static const unsigned __int128 1512 round_error() { return 0; } 1513 1514 static const int min_exponent = 0; 1515 static const int min_exponent10 = 0; 1516 static const int max_exponent = 0; 1517 static const int max_exponent10 = 0; 1518 1519 static const bool has_infinity = false; 1520 static const bool has_quiet_NaN = false; 1521 static const bool has_signaling_NaN = false; 1522 static const float_denorm_style has_denorm 1523 = denorm_absent; 1524 static const bool has_denorm_loss = false; 1525 1526 static const unsigned __int128 1527 infinity() 1528 { return static_cast<unsigned __int128>(0); } 1529 1530 static const unsigned __int128 1531 quiet_NaN() 1532 { return static_cast<unsigned __int128>(0); } 1533 1534 static const unsigned __int128 1535 signaling_NaN() 1536 { return static_cast<unsigned __int128>(0); } 1537 1538 static const unsigned __int128 1539 denorm_min() 1540 { return static_cast<unsigned __int128>(0); } 1541 1542 static const bool is_iec559 = false; 1543 static const bool is_bounded = true; 1544 static const bool is_modulo = true; 1545 1546 static const bool traps = __glibcxx_integral_traps; 1547 static const bool tinyness_before = false; 1548 static const float_round_style round_style 1549 = round_toward_zero; 1550 }; 1551#endif 1552 1553 /// numeric_limits<float> specialization. 1554 template<> 1555 struct numeric_limits<float> 1556 { 1557 static const bool is_specialized = true; 1558 1559 static const float 1560 min() { return FLT_MIN; } 1561 1562 static const float 1563 max() { return FLT_MAX; } 1564 1565#if __cplusplus >= 201103L 1566 static constexpr float 1567 lowest() noexcept { return -FLT_MAX; } 1568#endif 1569 1570 static const int digits = FLT_MANT_DIG; 1571 static const int digits10 = FLT_DIG; 1572#if __cplusplus >= 201103L 1573 static constexpr int max_digits10 1574 = __glibcxx_max_digits10 (FLT_MANT_DIG); 1575#endif 1576 static const bool is_signed = true; 1577 static const bool is_integer = false; 1578 static const bool is_exact = false; 1579 static const int radix = FLT_RADIX; 1580 1581 static const float 1582 epsilon() { return FLT_EPSILON; } 1583 1584 static const float 1585 round_error() { return 0.5F; } 1586 1587 static const int min_exponent = FLT_MIN_EXP; 1588 static const int min_exponent10 = FLT_MIN_10_EXP; 1589 static const int max_exponent = FLT_MAX_EXP; 1590 static const int max_exponent10 = FLT_MAX_10_EXP; 1591 1592 static const bool has_infinity = true; 1593 static const bool has_quiet_NaN = true; 1594 static const bool has_signaling_NaN = false; 1595 static const float_denorm_style has_denorm 1596 = denorm_present; 1597 static const bool has_denorm_loss 1598 = __glibcxx_float_has_denorm_loss; 1599 1600 static const float 1601 infinity() { return HUGE_VALF; } 1602 1603 static const float 1604 quiet_NaN() { return nanf(""); } 1605 1606 static const float 1607 signaling_NaN() { return nanf(""); } 1608 1609 static const float 1610 denorm_min() { return FLT_MIN; } 1611 1612 static const bool is_iec559 1613 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; 1614 static const bool is_bounded = true; 1615 static const bool is_modulo = false; 1616 1617 static const bool traps = __glibcxx_float_traps; 1618 static const bool tinyness_before 1619 = __glibcxx_float_tinyness_before; 1620 static const float_round_style round_style 1621 = round_to_nearest; 1622 }; 1623 1624#undef __glibcxx_float_has_denorm_loss 1625#undef __glibcxx_float_traps 1626#undef __glibcxx_float_tinyness_before 1627 1628 /// numeric_limits<double> specialization. 1629 template<> 1630 struct numeric_limits<double> 1631 { 1632 static const bool is_specialized = true; 1633 1634 static const double 1635 min() { return DBL_MIN; } 1636 1637 static const double 1638 max() { return DBL_MAX; } 1639 1640#if __cplusplus >= 201103L 1641 static constexpr double 1642 lowest() noexcept { return -DBL_MAX; } 1643#endif 1644 1645 static const int digits = DBL_MANT_DIG; 1646 static const int digits10 = DBL_DIG; 1647#if __cplusplus >= 201103L 1648 static constexpr int max_digits10 1649 = __glibcxx_max_digits10 (DBL_MANT_DIG); 1650#endif 1651 static const bool is_signed = true; 1652 static const bool is_integer = false; 1653 static const bool is_exact = false; 1654 static const int radix = FLT_RADIX; 1655 1656 static const double 1657 epsilon() { return DBL_EPSILON; } 1658 1659 static const double 1660 round_error() { return 0.5; } 1661 1662 static const int min_exponent = DBL_MIN_EXP; 1663 static const int min_exponent10 = DBL_MIN_10_EXP; 1664 static const int max_exponent = DBL_MAX_EXP; 1665 static const int max_exponent10 = DBL_MAX_10_EXP; 1666 1667 static const bool has_infinity = true; 1668 static const bool has_quiet_NaN = true; 1669 static const bool has_signaling_NaN = false; 1670 static const float_denorm_style has_denorm 1671 = denorm_present; 1672 static const bool has_denorm_loss 1673 = __glibcxx_double_has_denorm_loss; 1674 1675 static const double 1676 infinity() { return HUGE_VAL; } 1677 1678 static const double 1679 quiet_NaN() { return nan(""); } 1680 1681 static const double 1682 signaling_NaN() { return nan(""); } 1683 1684 static const double 1685 denorm_min() { return DBL_MIN; } 1686 1687 static const bool is_iec559 1688 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; 1689 static const bool is_bounded = true; 1690 static const bool is_modulo = false; 1691 1692 static const bool traps = __glibcxx_double_traps; 1693 static const bool tinyness_before 1694 = __glibcxx_double_tinyness_before; 1695 static const float_round_style round_style 1696 = round_to_nearest; 1697 }; 1698 1699#undef __glibcxx_double_has_denorm_loss 1700#undef __glibcxx_double_traps 1701#undef __glibcxx_double_tinyness_before 1702 1703 /// numeric_limits<long double> specialization. 1704 template<> 1705 struct numeric_limits<long double> 1706 { 1707 static const bool is_specialized = true; 1708 1709 static const long double 1710 min() { return LDBL_MIN; } 1711 1712 static const long double 1713 max() { return LDBL_MAX; } 1714 1715#if __cplusplus >= 201103L 1716 static constexpr long double 1717 lowest() noexcept { return -LDBL_MAX; } 1718#endif 1719 1720 static const int digits = LDBL_MANT_DIG; 1721 static const int digits10 = LDBL_DIG; 1722#if __cplusplus >= 201103L 1723 static const int max_digits10 1724 = __glibcxx_max_digits10 (LDBL_MANT_DIG); 1725#endif 1726 static const bool is_signed = true; 1727 static const bool is_integer = false; 1728 static const bool is_exact = false; 1729 static const int radix = FLT_RADIX; 1730 1731 static const long double 1732 epsilon() { return LDBL_EPSILON; } 1733 1734 static const long double 1735 round_error() { return 0.5L; } 1736 1737 static const int min_exponent = LDBL_MIN_EXP; 1738 static const int min_exponent10 = LDBL_MIN_10_EXP; 1739 static const int max_exponent = LDBL_MAX_EXP; 1740 static const int max_exponent10 = LDBL_MAX_10_EXP; 1741 1742 static const bool has_infinity = true; 1743 static const bool has_quiet_NaN = true; 1744 static const bool has_signaling_NaN = false; 1745 static const float_denorm_style has_denorm 1746 = denorm_present; 1747 static const bool has_denorm_loss 1748 = __glibcxx_long_double_has_denorm_loss; 1749 1750 static const long double 1751 infinity() { return HUGE_VAL; } 1752 1753 static const long double 1754 quiet_NaN() { return nanl(""); } 1755 1756 static const long double 1757 signaling_NaN() { return nanl(""); } 1758 1759 static const long double 1760 denorm_min() { return LDBL_MIN; } 1761 1762 static const bool is_iec559 1763 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; 1764 static const bool is_bounded = true; 1765 static const bool is_modulo = false; 1766 1767 static const bool traps = __glibcxx_long_double_traps; 1768 static const bool tinyness_before = 1769 __glibcxx_long_double_tinyness_before; 1770 static const float_round_style round_style = 1771 round_to_nearest; 1772 }; 1773 1774#undef __glibcxx_long_double_has_denorm_loss 1775#undef __glibcxx_long_double_traps 1776#undef __glibcxx_long_double_tinyness_before 1777 1778} // namespace 1779 1780#undef __glibcxx_signed 1781#undef __glibcxx_min 1782#undef __glibcxx_max 1783#undef __glibcxx_digits 1784#undef __glibcxx_digits10 1785#undef __glibcxx_max_digits10 1786 1787#endif // _GLIBCXX_NUMERIC_LIMITS 1788