- tmp/tmpe981amnl/{from.md → to.md} +219 -136
tmp/tmpe981amnl/{from.md → to.md}
RENAMED
|
@@ -1,41 +1,25 @@
|
|
| 1 |
## Implementation properties <a id="support.limits">[[support.limits]]</a>
|
| 2 |
|
| 3 |
-
###
|
| 4 |
|
| 5 |
-
The headers `<limits>` ([[limits]]), `<climits>`
|
| 6 |
-
[[
|
| 7 |
-
arithmetic types (
|
|
|
|
| 8 |
|
| 9 |
-
###
|
| 10 |
-
|
| 11 |
-
#### Class template `numeric_limits` <a id="limits.numeric">[[limits.numeric]]</a>
|
| 12 |
-
|
| 13 |
-
The `numeric_limits` class template provides a C++program with
|
| 14 |
-
information about various properties of the implementation’s
|
| 15 |
-
representation of the arithmetic types.
|
| 16 |
-
|
| 17 |
-
Specializations shall be provided for each arithmetic type, both
|
| 18 |
-
floating point and integer, including `bool`. The member
|
| 19 |
-
`is_specialized` shall be `true` for all such specializations of
|
| 20 |
-
`numeric_limits`.
|
| 21 |
-
|
| 22 |
-
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 23 |
-
template, specializations shall define these values in such a way that
|
| 24 |
-
they are usable as constant expressions.
|
| 25 |
-
|
| 26 |
-
Non-arithmetic standard types, such as `complex<T>` ([[complex]]),
|
| 27 |
-
shall not have specializations.
|
| 28 |
-
|
| 29 |
-
#### Header `<limits>` synopsis <a id="limits.syn">[[limits.syn]]</a>
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
namespace std {
|
| 33 |
-
|
| 34 |
enum float_round_style;
|
| 35 |
enum float_denorm_style;
|
| 36 |
|
|
|
|
|
|
|
|
|
|
| 37 |
template<> class numeric_limits<bool>;
|
| 38 |
|
| 39 |
template<> class numeric_limits<char>;
|
| 40 |
template<> class numeric_limits<signed char>;
|
| 41 |
template<> class numeric_limits<unsigned char>;
|
|
@@ -56,11 +40,62 @@ namespace std {
|
|
| 56 |
template<> class numeric_limits<double>;
|
| 57 |
template<> class numeric_limits<long double>;
|
| 58 |
}
|
| 59 |
```
|
| 60 |
|
| 61 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
``` cpp
|
| 64 |
namespace std {
|
| 65 |
template<class T> class numeric_limits {
|
| 66 |
public:
|
|
@@ -107,26 +142,41 @@ namespace std {
|
|
| 107 |
template<class T> class numeric_limits<volatile T>;
|
| 108 |
template<class T> class numeric_limits<const volatile T>;
|
| 109 |
}
|
| 110 |
```
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
The default `numeric_limits<T>` template shall have all members, but
|
| 113 |
with 0 or `false` values.
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
The value of each member of a specialization of `numeric_limits` on a
|
| 116 |
-
|
| 117 |
corresponding member of the specialization on the unqualified type `T`.
|
| 118 |
|
|
|
|
|
|
|
|
|
|
| 119 |
#### `numeric_limits` members <a id="numeric.limits.members">[[numeric.limits.members]]</a>
|
| 120 |
|
|
|
|
|
|
|
|
|
|
| 121 |
``` cpp
|
| 122 |
static constexpr T min() noexcept;
|
| 123 |
```
|
| 124 |
|
| 125 |
Minimum finite value.[^3]
|
| 126 |
|
| 127 |
-
For floating types with
|
| 128 |
normalized value.
|
| 129 |
|
| 130 |
Meaningful for all specializations in which `is_bounded != false`, or
|
| 131 |
`is_bounded == false && is_signed == false`.
|
| 132 |
|
|
@@ -153,11 +203,11 @@ static constexpr int digits;
|
|
| 153 |
|
| 154 |
Number of `radix` digits that can be represented without change.
|
| 155 |
|
| 156 |
For integer types, the number of non-sign bits in the representation.
|
| 157 |
|
| 158 |
-
For floating
|
| 159 |
mantissa.[^6]
|
| 160 |
|
| 161 |
``` cpp
|
| 162 |
static constexpr int digits10;
|
| 163 |
```
|
|
@@ -171,33 +221,33 @@ static constexpr int max_digits10;
|
|
| 171 |
```
|
| 172 |
|
| 173 |
Number of base 10 digits required to ensure that values which differ are
|
| 174 |
always differentiated.
|
| 175 |
|
| 176 |
-
Meaningful for all floating
|
| 177 |
|
| 178 |
``` cpp
|
| 179 |
static constexpr bool is_signed;
|
| 180 |
```
|
| 181 |
|
| 182 |
-
|
| 183 |
|
| 184 |
Meaningful for all specializations.
|
| 185 |
|
| 186 |
``` cpp
|
| 187 |
static constexpr bool is_integer;
|
| 188 |
```
|
| 189 |
|
| 190 |
-
|
| 191 |
|
| 192 |
Meaningful for all specializations.
|
| 193 |
|
| 194 |
``` cpp
|
| 195 |
static constexpr bool is_exact;
|
| 196 |
```
|
| 197 |
|
| 198 |
-
|
| 199 |
exact, but not all exact types are integer. For example, rational and
|
| 200 |
fixed-exponent representations are exact but not integer.
|
| 201 |
|
| 202 |
Meaningful for all specializations.
|
| 203 |
|
|
@@ -217,11 +267,11 @@ static constexpr T epsilon() noexcept;
|
|
| 217 |
```
|
| 218 |
|
| 219 |
Machine epsilon: the difference between 1 and the least value greater
|
| 220 |
than 1 that is representable.[^10]
|
| 221 |
|
| 222 |
-
Meaningful for all floating
|
| 223 |
|
| 224 |
``` cpp
|
| 225 |
static constexpr T round_error() noexcept;
|
| 226 |
```
|
| 227 |
|
|
@@ -230,89 +280,89 @@ Measure of the maximum rounding error.[^11]
|
|
| 230 |
``` cpp
|
| 231 |
static constexpr int min_exponent;
|
| 232 |
```
|
| 233 |
|
| 234 |
Minimum negative integer such that `radix` raised to the power of one
|
| 235 |
-
less than that integer is a normalized floating
|
| 236 |
|
| 237 |
-
Meaningful for all floating
|
| 238 |
|
| 239 |
``` cpp
|
| 240 |
static constexpr int min_exponent10;
|
| 241 |
```
|
| 242 |
|
| 243 |
Minimum negative integer such that 10 raised to that power is in the
|
| 244 |
-
range of normalized floating
|
| 245 |
|
| 246 |
-
Meaningful for all floating
|
| 247 |
|
| 248 |
``` cpp
|
| 249 |
static constexpr int max_exponent;
|
| 250 |
```
|
| 251 |
|
| 252 |
Maximum positive integer such that `radix` raised to the power one less
|
| 253 |
-
than that integer is a representable finite floating
|
| 254 |
|
| 255 |
-
Meaningful for all floating
|
| 256 |
|
| 257 |
``` cpp
|
| 258 |
static constexpr int max_exponent10;
|
| 259 |
```
|
| 260 |
|
| 261 |
Maximum positive integer such that 10 raised to that power is in the
|
| 262 |
-
range of representable finite floating
|
| 263 |
|
| 264 |
-
Meaningful for all floating
|
| 265 |
|
| 266 |
``` cpp
|
| 267 |
static constexpr bool has_infinity;
|
| 268 |
```
|
| 269 |
|
| 270 |
-
|
| 271 |
|
| 272 |
-
Meaningful for all floating
|
| 273 |
|
| 274 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 275 |
|
| 276 |
``` cpp
|
| 277 |
static constexpr bool has_quiet_NaN;
|
| 278 |
```
|
| 279 |
|
| 280 |
-
|
| 281 |
-
Number
|
| 282 |
|
| 283 |
-
Meaningful for all floating
|
| 284 |
|
| 285 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 286 |
|
| 287 |
``` cpp
|
| 288 |
static constexpr bool has_signaling_NaN;
|
| 289 |
```
|
| 290 |
|
| 291 |
-
|
| 292 |
-
Number
|
| 293 |
|
| 294 |
-
Meaningful for all floating
|
| 295 |
|
| 296 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 297 |
|
| 298 |
``` cpp
|
| 299 |
static constexpr float_denorm_style has_denorm;
|
| 300 |
```
|
| 301 |
|
| 302 |
-
`denorm_present` if the type allows
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
|
| 307 |
-
Meaningful for all floating
|
| 308 |
|
| 309 |
``` cpp
|
| 310 |
static constexpr bool has_denorm_loss;
|
| 311 |
```
|
| 312 |
|
| 313 |
-
|
| 314 |
than as an inexact result.[^19]
|
| 315 |
|
| 316 |
``` cpp
|
| 317 |
static constexpr T infinity() noexcept;
|
| 318 |
```
|
|
@@ -324,65 +374,70 @@ Required in specializations for which `is_iec559 != false`.
|
|
| 324 |
|
| 325 |
``` cpp
|
| 326 |
static constexpr T quiet_NaN() noexcept;
|
| 327 |
```
|
| 328 |
|
| 329 |
-
Representation of a quiet “Not a Number
|
| 330 |
|
| 331 |
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 332 |
Required in specializations for which `is_iec559 != false`.
|
| 333 |
|
| 334 |
``` cpp
|
| 335 |
static constexpr T signaling_NaN() noexcept;
|
| 336 |
```
|
| 337 |
|
| 338 |
-
Representation of a signaling “Not a Number
|
| 339 |
|
| 340 |
Meaningful for all specializations for which
|
| 341 |
`has_signaling_NaN != false`. Required in specializations for which
|
| 342 |
`is_iec559 != false`.
|
| 343 |
|
| 344 |
``` cpp
|
| 345 |
static constexpr T denorm_min() noexcept;
|
| 346 |
```
|
| 347 |
|
| 348 |
-
Minimum positive
|
| 349 |
|
| 350 |
-
Meaningful for all floating
|
| 351 |
|
| 352 |
In specializations for which `has_denorm == false`, returns the minimum
|
| 353 |
positive normalized value.
|
| 354 |
|
| 355 |
``` cpp
|
| 356 |
static constexpr bool is_iec559;
|
| 357 |
```
|
| 358 |
|
| 359 |
-
|
| 360 |
|
| 361 |
-
Meaningful for all floating
|
| 362 |
|
| 363 |
``` cpp
|
| 364 |
static constexpr bool is_bounded;
|
| 365 |
```
|
| 366 |
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
|
|
|
|
|
|
| 370 |
|
| 371 |
Meaningful for all specializations.
|
| 372 |
|
| 373 |
``` cpp
|
| 374 |
static constexpr bool is_modulo;
|
| 375 |
```
|
| 376 |
|
| 377 |
-
|
| 378 |
-
involving `+`, `-`, or `*` on values of that type whose result
|
| 379 |
-
fall outside the range \[`min()`, `max()`\], the value returned
|
| 380 |
-
from the true value by an integer multiple of
|
|
|
|
| 381 |
|
| 382 |
-
|
| 383 |
-
|
|
|
|
|
|
|
| 384 |
|
| 385 |
Meaningful for all specializations.
|
| 386 |
|
| 387 |
``` cpp
|
| 388 |
static constexpr bool traps;
|
|
@@ -397,94 +452,51 @@ Meaningful for all specializations.
|
|
| 397 |
static constexpr bool tinyness_before;
|
| 398 |
```
|
| 399 |
|
| 400 |
`true` if tinyness is detected before rounding.[^28]
|
| 401 |
|
| 402 |
-
Meaningful for all floating
|
| 403 |
|
| 404 |
``` cpp
|
| 405 |
static constexpr float_round_style round_style;
|
| 406 |
```
|
| 407 |
|
| 408 |
The rounding style for the type.[^29]
|
| 409 |
|
| 410 |
-
Meaningful for all floating
|
| 411 |
types shall return `round_toward_zero`.
|
| 412 |
|
| 413 |
-
#### Type `float_round_style` <a id="round.style">[[round.style]]</a>
|
| 414 |
-
|
| 415 |
-
``` cpp
|
| 416 |
-
namespace std {
|
| 417 |
-
enum float_round_style {
|
| 418 |
-
round_indeterminate = -1,
|
| 419 |
-
round_toward_zero = 0,
|
| 420 |
-
round_to_nearest = 1,
|
| 421 |
-
round_toward_infinity = 2,
|
| 422 |
-
round_toward_neg_infinity = 3
|
| 423 |
-
};
|
| 424 |
-
}
|
| 425 |
-
```
|
| 426 |
-
|
| 427 |
-
The rounding mode for floating point arithmetic is characterized by the
|
| 428 |
-
values:
|
| 429 |
-
|
| 430 |
-
- `round_indeterminate` if the rounding style is indeterminable
|
| 431 |
-
- `round_toward_zero` if the rounding style is toward zero
|
| 432 |
-
- `round_to_nearest` if the rounding style is to the nearest
|
| 433 |
-
representable value
|
| 434 |
-
- `round_toward_infinity` if the rounding style is toward infinity
|
| 435 |
-
- `round_toward_neg_infinity` if the rounding style is toward negative
|
| 436 |
-
infinity
|
| 437 |
-
|
| 438 |
-
#### Type `float_denorm_style` <a id="denorm.style">[[denorm.style]]</a>
|
| 439 |
-
|
| 440 |
-
``` cpp
|
| 441 |
-
namespace std {
|
| 442 |
-
enum float_denorm_style {
|
| 443 |
-
denorm_indeterminate = -1,
|
| 444 |
-
denorm_absent = 0,
|
| 445 |
-
denorm_present = 1
|
| 446 |
-
};
|
| 447 |
-
}
|
| 448 |
-
```
|
| 449 |
-
|
| 450 |
-
The presence or absence of denormalization (variable number of exponent
|
| 451 |
-
bits) is characterized by the values:
|
| 452 |
-
|
| 453 |
-
- `denorm_indeterminate` if it cannot be determined whether or not the
|
| 454 |
-
type allows denormalized values
|
| 455 |
-
- `denorm_absent` if the type does not allow denormalized values
|
| 456 |
-
- `denorm_present` if the type does allow denormalized values
|
| 457 |
-
|
| 458 |
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
| 459 |
|
| 460 |
All members shall be provided for all specializations. However, many
|
| 461 |
values are only required to be meaningful under certain conditions (for
|
| 462 |
example, `epsilon()` is only meaningful if `is_integer` is `false`). Any
|
| 463 |
value that is not “meaningful” shall be set to 0 or `false`.
|
| 464 |
|
|
|
|
|
|
|
| 465 |
``` cpp
|
| 466 |
namespace std {
|
| 467 |
template<> class numeric_limits<float> {
|
| 468 |
public:
|
| 469 |
static constexpr bool is_specialized = true;
|
| 470 |
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
|
| 475 |
static constexpr int digits = 24;
|
| 476 |
static constexpr int digits10 = 6;
|
| 477 |
static constexpr int max_digits10 = 9;
|
| 478 |
|
| 479 |
static constexpr bool is_signed = true;
|
| 480 |
static constexpr bool is_integer = false;
|
| 481 |
static constexpr bool is_exact = false;
|
| 482 |
|
| 483 |
static constexpr int radix = 2;
|
| 484 |
-
|
| 485 |
-
|
| 486 |
|
| 487 |
static constexpr int min_exponent = -125;
|
| 488 |
static constexpr int min_exponent10 = - 37;
|
| 489 |
static constexpr int max_exponent = +128;
|
| 490 |
static constexpr int max_exponent10 = + 38;
|
|
@@ -493,14 +505,14 @@ namespace std {
|
|
| 493 |
static constexpr bool has_quiet_NaN = true;
|
| 494 |
static constexpr bool has_signaling_NaN = true;
|
| 495 |
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 496 |
static constexpr bool has_denorm_loss = false;
|
| 497 |
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
|
| 503 |
static constexpr bool is_iec559 = true;
|
| 504 |
static constexpr bool is_bounded = true;
|
| 505 |
static constexpr bool is_modulo = false;
|
| 506 |
static constexpr bool traps = true;
|
|
@@ -509,10 +521,12 @@ namespace std {
|
|
| 509 |
static constexpr float_round_style round_style = round_to_nearest;
|
| 510 |
};
|
| 511 |
}
|
| 512 |
```
|
| 513 |
|
|
|
|
|
|
|
| 514 |
The specialization for `bool` shall be provided as follows:
|
| 515 |
|
| 516 |
``` cpp
|
| 517 |
namespace std {
|
| 518 |
template<> class numeric_limits<bool> {
|
|
@@ -557,19 +571,88 @@ namespace std {
|
|
| 557 |
static constexpr float_round_style round_style = round_toward_zero;
|
| 558 |
};
|
| 559 |
}
|
| 560 |
```
|
| 561 |
|
| 562 |
-
###
|
| 563 |
|
| 564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
|
| 566 |
-
The
|
| 567 |
-
|
| 568 |
-
required to match the types to which the macros refer.
|
| 569 |
|
| 570 |
-
|
|
|
|
|
|
|
| 571 |
|
| 572 |
-
|
| 573 |
|
| 574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
|
|
|
|
| 1 |
## Implementation properties <a id="support.limits">[[support.limits]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="support.limits.general">[[support.limits.general]]</a>
|
| 4 |
|
| 5 |
+
The headers `<limits>` ([[limits.syn]]), `<climits>` (
|
| 6 |
+
[[climits.syn]]), and `<cfloat>` ([[cfloat.syn]]) supply
|
| 7 |
+
characteristics of implementation-dependent arithmetic types (
|
| 8 |
+
[[basic.fundamental]]).
|
| 9 |
|
| 10 |
+
### Header `<limits>` synopsis <a id="limits.syn">[[limits.syn]]</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
``` cpp
|
| 13 |
namespace std {
|
| 14 |
+
// [fp.style], floating-point type properties
|
| 15 |
enum float_round_style;
|
| 16 |
enum float_denorm_style;
|
| 17 |
|
| 18 |
+
// [numeric.limits], class template numeric_limits
|
| 19 |
+
template<class T> class numeric_limits;
|
| 20 |
+
|
| 21 |
template<> class numeric_limits<bool>;
|
| 22 |
|
| 23 |
template<> class numeric_limits<char>;
|
| 24 |
template<> class numeric_limits<signed char>;
|
| 25 |
template<> class numeric_limits<unsigned char>;
|
|
|
|
| 40 |
template<> class numeric_limits<double>;
|
| 41 |
template<> class numeric_limits<long double>;
|
| 42 |
}
|
| 43 |
```
|
| 44 |
|
| 45 |
+
### Floating-point type properties <a id="fp.style">[[fp.style]]</a>
|
| 46 |
+
|
| 47 |
+
#### Type `float_round_style` <a id="round.style">[[round.style]]</a>
|
| 48 |
+
|
| 49 |
+
``` cpp
|
| 50 |
+
namespace std {
|
| 51 |
+
enum float_round_style {
|
| 52 |
+
round_indeterminate = -1,
|
| 53 |
+
round_toward_zero = 0,
|
| 54 |
+
round_to_nearest = 1,
|
| 55 |
+
round_toward_infinity = 2,
|
| 56 |
+
round_toward_neg_infinity = 3
|
| 57 |
+
};
|
| 58 |
+
}
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
The rounding mode for floating-point arithmetic is characterized by the
|
| 62 |
+
values:
|
| 63 |
+
|
| 64 |
+
- `round_indeterminate` if the rounding style is indeterminable
|
| 65 |
+
- `round_toward_zero` if the rounding style is toward zero
|
| 66 |
+
- `round_to_nearest` if the rounding style is to the nearest
|
| 67 |
+
representable value
|
| 68 |
+
- `round_toward_infinity` if the rounding style is toward infinity
|
| 69 |
+
- `round_toward_neg_infinity` if the rounding style is toward negative
|
| 70 |
+
infinity
|
| 71 |
+
|
| 72 |
+
#### Type `float_denorm_style` <a id="denorm.style">[[denorm.style]]</a>
|
| 73 |
+
|
| 74 |
+
``` cpp
|
| 75 |
+
namespace std {
|
| 76 |
+
enum float_denorm_style {
|
| 77 |
+
denorm_indeterminate = -1,
|
| 78 |
+
denorm_absent = 0,
|
| 79 |
+
denorm_present = 1
|
| 80 |
+
};
|
| 81 |
+
}
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
The presence or absence of subnormal numbers (variable number of
|
| 85 |
+
exponent bits) is characterized by the values:
|
| 86 |
+
|
| 87 |
+
- `denorm_indeterminate` if it cannot be determined whether or not the
|
| 88 |
+
type allows subnormal values
|
| 89 |
+
- `denorm_absent` if the type does not allow subnormal values
|
| 90 |
+
- `denorm_present` if the type does allow subnormal values
|
| 91 |
+
|
| 92 |
+
### Class template `numeric_limits` <a id="numeric.limits">[[numeric.limits]]</a>
|
| 93 |
+
|
| 94 |
+
The `numeric_limits` class template provides a C++program with
|
| 95 |
+
information about various properties of the implementation’s
|
| 96 |
+
representation of the arithmetic types.
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
namespace std {
|
| 100 |
template<class T> class numeric_limits {
|
| 101 |
public:
|
|
|
|
| 142 |
template<class T> class numeric_limits<volatile T>;
|
| 143 |
template<class T> class numeric_limits<const volatile T>;
|
| 144 |
}
|
| 145 |
```
|
| 146 |
|
| 147 |
+
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 148 |
+
template, specializations shall define these values in such a way that
|
| 149 |
+
they are usable as constant expressions.
|
| 150 |
+
|
| 151 |
The default `numeric_limits<T>` template shall have all members, but
|
| 152 |
with 0 or `false` values.
|
| 153 |
|
| 154 |
+
Specializations shall be provided for each arithmetic type, both
|
| 155 |
+
floating-point and integer, including `bool`. The member
|
| 156 |
+
`is_specialized` shall be `true` for all such specializations of
|
| 157 |
+
`numeric_limits`.
|
| 158 |
+
|
| 159 |
The value of each member of a specialization of `numeric_limits` on a
|
| 160 |
+
cv-qualified type `cv T` shall be equal to the value of the
|
| 161 |
corresponding member of the specialization on the unqualified type `T`.
|
| 162 |
|
| 163 |
+
Non-arithmetic standard types, such as `complex<T>` ([[complex]]),
|
| 164 |
+
shall not have specializations.
|
| 165 |
+
|
| 166 |
#### `numeric_limits` members <a id="numeric.limits.members">[[numeric.limits.members]]</a>
|
| 167 |
|
| 168 |
+
Each member function defined in this subclause is signal-safe (
|
| 169 |
+
[[csignal.syn]]).
|
| 170 |
+
|
| 171 |
``` cpp
|
| 172 |
static constexpr T min() noexcept;
|
| 173 |
```
|
| 174 |
|
| 175 |
Minimum finite value.[^3]
|
| 176 |
|
| 177 |
+
For floating types with subnormal numbers, returns the minimum positive
|
| 178 |
normalized value.
|
| 179 |
|
| 180 |
Meaningful for all specializations in which `is_bounded != false`, or
|
| 181 |
`is_bounded == false && is_signed == false`.
|
| 182 |
|
|
|
|
| 203 |
|
| 204 |
Number of `radix` digits that can be represented without change.
|
| 205 |
|
| 206 |
For integer types, the number of non-sign bits in the representation.
|
| 207 |
|
| 208 |
+
For floating-point types, the number of `radix` digits in the
|
| 209 |
mantissa.[^6]
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
static constexpr int digits10;
|
| 213 |
```
|
|
|
|
| 221 |
```
|
| 222 |
|
| 223 |
Number of base 10 digits required to ensure that values which differ are
|
| 224 |
always differentiated.
|
| 225 |
|
| 226 |
+
Meaningful for all floating-point types.
|
| 227 |
|
| 228 |
``` cpp
|
| 229 |
static constexpr bool is_signed;
|
| 230 |
```
|
| 231 |
|
| 232 |
+
`true` if the type is signed.
|
| 233 |
|
| 234 |
Meaningful for all specializations.
|
| 235 |
|
| 236 |
``` cpp
|
| 237 |
static constexpr bool is_integer;
|
| 238 |
```
|
| 239 |
|
| 240 |
+
`true` if the type is integer.
|
| 241 |
|
| 242 |
Meaningful for all specializations.
|
| 243 |
|
| 244 |
``` cpp
|
| 245 |
static constexpr bool is_exact;
|
| 246 |
```
|
| 247 |
|
| 248 |
+
`true` if the type uses an exact representation. All integer types are
|
| 249 |
exact, but not all exact types are integer. For example, rational and
|
| 250 |
fixed-exponent representations are exact but not integer.
|
| 251 |
|
| 252 |
Meaningful for all specializations.
|
| 253 |
|
|
|
|
| 267 |
```
|
| 268 |
|
| 269 |
Machine epsilon: the difference between 1 and the least value greater
|
| 270 |
than 1 that is representable.[^10]
|
| 271 |
|
| 272 |
+
Meaningful for all floating-point types.
|
| 273 |
|
| 274 |
``` cpp
|
| 275 |
static constexpr T round_error() noexcept;
|
| 276 |
```
|
| 277 |
|
|
|
|
| 280 |
``` cpp
|
| 281 |
static constexpr int min_exponent;
|
| 282 |
```
|
| 283 |
|
| 284 |
Minimum negative integer such that `radix` raised to the power of one
|
| 285 |
+
less than that integer is a normalized floating-point number.[^12]
|
| 286 |
|
| 287 |
+
Meaningful for all floating-point types.
|
| 288 |
|
| 289 |
``` cpp
|
| 290 |
static constexpr int min_exponent10;
|
| 291 |
```
|
| 292 |
|
| 293 |
Minimum negative integer such that 10 raised to that power is in the
|
| 294 |
+
range of normalized floating-point numbers.[^13]
|
| 295 |
|
| 296 |
+
Meaningful for all floating-point types.
|
| 297 |
|
| 298 |
``` cpp
|
| 299 |
static constexpr int max_exponent;
|
| 300 |
```
|
| 301 |
|
| 302 |
Maximum positive integer such that `radix` raised to the power one less
|
| 303 |
+
than that integer is a representable finite floating-point number.[^14]
|
| 304 |
|
| 305 |
+
Meaningful for all floating-point types.
|
| 306 |
|
| 307 |
``` cpp
|
| 308 |
static constexpr int max_exponent10;
|
| 309 |
```
|
| 310 |
|
| 311 |
Maximum positive integer such that 10 raised to that power is in the
|
| 312 |
+
range of representable finite floating-point numbers.[^15]
|
| 313 |
|
| 314 |
+
Meaningful for all floating-point types.
|
| 315 |
|
| 316 |
``` cpp
|
| 317 |
static constexpr bool has_infinity;
|
| 318 |
```
|
| 319 |
|
| 320 |
+
`true` if the type has a representation for positive infinity.
|
| 321 |
|
| 322 |
+
Meaningful for all floating-point types.
|
| 323 |
|
| 324 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 325 |
|
| 326 |
``` cpp
|
| 327 |
static constexpr bool has_quiet_NaN;
|
| 328 |
```
|
| 329 |
|
| 330 |
+
`true` if the type has a representation for a quiet (non-signaling) “Not
|
| 331 |
+
a Number”.[^16]
|
| 332 |
|
| 333 |
+
Meaningful for all floating-point types.
|
| 334 |
|
| 335 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 336 |
|
| 337 |
``` cpp
|
| 338 |
static constexpr bool has_signaling_NaN;
|
| 339 |
```
|
| 340 |
|
| 341 |
+
`true` if the type has a representation for a signaling “Not a
|
| 342 |
+
Number”.[^17]
|
| 343 |
|
| 344 |
+
Meaningful for all floating-point types.
|
| 345 |
|
| 346 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 347 |
|
| 348 |
``` cpp
|
| 349 |
static constexpr float_denorm_style has_denorm;
|
| 350 |
```
|
| 351 |
|
| 352 |
+
`denorm_present` if the type allows subnormal values (variable number of
|
| 353 |
+
exponent bits)[^18], `denorm_absent` if the type does not allow
|
| 354 |
+
subnormal values, and `denorm_indeterminate` if it is indeterminate at
|
| 355 |
+
compile time whether the type allows subnormal values.
|
| 356 |
|
| 357 |
+
Meaningful for all floating-point types.
|
| 358 |
|
| 359 |
``` cpp
|
| 360 |
static constexpr bool has_denorm_loss;
|
| 361 |
```
|
| 362 |
|
| 363 |
+
`true` if loss of accuracy is detected as a denormalization loss, rather
|
| 364 |
than as an inexact result.[^19]
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
static constexpr T infinity() noexcept;
|
| 368 |
```
|
|
|
|
| 374 |
|
| 375 |
``` cpp
|
| 376 |
static constexpr T quiet_NaN() noexcept;
|
| 377 |
```
|
| 378 |
|
| 379 |
+
Representation of a quiet “Not a Number”, if available.[^21]
|
| 380 |
|
| 381 |
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 382 |
Required in specializations for which `is_iec559 != false`.
|
| 383 |
|
| 384 |
``` cpp
|
| 385 |
static constexpr T signaling_NaN() noexcept;
|
| 386 |
```
|
| 387 |
|
| 388 |
+
Representation of a signaling “Not a Number”, if available.[^22]
|
| 389 |
|
| 390 |
Meaningful for all specializations for which
|
| 391 |
`has_signaling_NaN != false`. Required in specializations for which
|
| 392 |
`is_iec559 != false`.
|
| 393 |
|
| 394 |
``` cpp
|
| 395 |
static constexpr T denorm_min() noexcept;
|
| 396 |
```
|
| 397 |
|
| 398 |
+
Minimum positive subnormal value.[^23]
|
| 399 |
|
| 400 |
+
Meaningful for all floating-point types.
|
| 401 |
|
| 402 |
In specializations for which `has_denorm == false`, returns the minimum
|
| 403 |
positive normalized value.
|
| 404 |
|
| 405 |
``` cpp
|
| 406 |
static constexpr bool is_iec559;
|
| 407 |
```
|
| 408 |
|
| 409 |
+
`true` if and only if the type adheres to ISO/IEC/IEEE 60559.[^24]
|
| 410 |
|
| 411 |
+
Meaningful for all floating-point types.
|
| 412 |
|
| 413 |
``` cpp
|
| 414 |
static constexpr bool is_bounded;
|
| 415 |
```
|
| 416 |
|
| 417 |
+
`true` if the set of values representable by the type is finite.[^25]
|
| 418 |
+
|
| 419 |
+
[*Note 1*: All fundamental types ([[basic.fundamental]]) are bounded.
|
| 420 |
+
This member would be `false` for arbitrary precision
|
| 421 |
+
types. — *end note*]
|
| 422 |
|
| 423 |
Meaningful for all specializations.
|
| 424 |
|
| 425 |
``` cpp
|
| 426 |
static constexpr bool is_modulo;
|
| 427 |
```
|
| 428 |
|
| 429 |
+
`true` if the type is modulo.[^26] A type is modulo if, for any
|
| 430 |
+
operation involving `+`, `-`, or `*` on values of that type whose result
|
| 431 |
+
would fall outside the range \[`min()`, `max()`\], the value returned
|
| 432 |
+
differs from the true value by an integer multiple of
|
| 433 |
+
`max() - min() + 1`.
|
| 434 |
|
| 435 |
+
[*Example 1*: `is_modulo` is `false` for signed integer
|
| 436 |
+
types ([[basic.fundamental]]) unless an implementation, as an extension
|
| 437 |
+
to this International Standard, defines signed integer overflow to
|
| 438 |
+
wrap. — *end example*]
|
| 439 |
|
| 440 |
Meaningful for all specializations.
|
| 441 |
|
| 442 |
``` cpp
|
| 443 |
static constexpr bool traps;
|
|
|
|
| 452 |
static constexpr bool tinyness_before;
|
| 453 |
```
|
| 454 |
|
| 455 |
`true` if tinyness is detected before rounding.[^28]
|
| 456 |
|
| 457 |
+
Meaningful for all floating-point types.
|
| 458 |
|
| 459 |
``` cpp
|
| 460 |
static constexpr float_round_style round_style;
|
| 461 |
```
|
| 462 |
|
| 463 |
The rounding style for the type.[^29]
|
| 464 |
|
| 465 |
+
Meaningful for all floating-point types. Specializations for integer
|
| 466 |
types shall return `round_toward_zero`.
|
| 467 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
| 469 |
|
| 470 |
All members shall be provided for all specializations. However, many
|
| 471 |
values are only required to be meaningful under certain conditions (for
|
| 472 |
example, `epsilon()` is only meaningful if `is_integer` is `false`). Any
|
| 473 |
value that is not “meaningful” shall be set to 0 or `false`.
|
| 474 |
|
| 475 |
+
[*Example 1*:
|
| 476 |
+
|
| 477 |
``` cpp
|
| 478 |
namespace std {
|
| 479 |
template<> class numeric_limits<float> {
|
| 480 |
public:
|
| 481 |
static constexpr bool is_specialized = true;
|
| 482 |
|
| 483 |
+
static constexpr float min() noexcept { return 1.17549435E-38F; }
|
| 484 |
+
static constexpr float max() noexcept { return 3.40282347E+38F; }
|
| 485 |
+
static constexpr float lowest() noexcept { return -3.40282347E+38F; }
|
| 486 |
|
| 487 |
static constexpr int digits = 24;
|
| 488 |
static constexpr int digits10 = 6;
|
| 489 |
static constexpr int max_digits10 = 9;
|
| 490 |
|
| 491 |
static constexpr bool is_signed = true;
|
| 492 |
static constexpr bool is_integer = false;
|
| 493 |
static constexpr bool is_exact = false;
|
| 494 |
|
| 495 |
static constexpr int radix = 2;
|
| 496 |
+
static constexpr float epsilon() noexcept { return 1.19209290E-07F; }
|
| 497 |
+
static constexpr float round_error() noexcept { return 0.5F; }
|
| 498 |
|
| 499 |
static constexpr int min_exponent = -125;
|
| 500 |
static constexpr int min_exponent10 = - 37;
|
| 501 |
static constexpr int max_exponent = +128;
|
| 502 |
static constexpr int max_exponent10 = + 38;
|
|
|
|
| 505 |
static constexpr bool has_quiet_NaN = true;
|
| 506 |
static constexpr bool has_signaling_NaN = true;
|
| 507 |
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 508 |
static constexpr bool has_denorm_loss = false;
|
| 509 |
|
| 510 |
+
static constexpr float infinity() noexcept { return value; }
|
| 511 |
+
static constexpr float quiet_NaN() noexcept { return value; }
|
| 512 |
+
static constexpr float signaling_NaN() noexcept { return value; }
|
| 513 |
+
static constexpr float denorm_min() noexcept { return min(); }
|
| 514 |
|
| 515 |
static constexpr bool is_iec559 = true;
|
| 516 |
static constexpr bool is_bounded = true;
|
| 517 |
static constexpr bool is_modulo = false;
|
| 518 |
static constexpr bool traps = true;
|
|
|
|
| 521 |
static constexpr float_round_style round_style = round_to_nearest;
|
| 522 |
};
|
| 523 |
}
|
| 524 |
```
|
| 525 |
|
| 526 |
+
— *end example*]
|
| 527 |
+
|
| 528 |
The specialization for `bool` shall be provided as follows:
|
| 529 |
|
| 530 |
``` cpp
|
| 531 |
namespace std {
|
| 532 |
template<> class numeric_limits<bool> {
|
|
|
|
| 571 |
static constexpr float_round_style round_style = round_toward_zero;
|
| 572 |
};
|
| 573 |
}
|
| 574 |
```
|
| 575 |
|
| 576 |
+
### Header `<climits>` synopsis <a id="climits.syn">[[climits.syn]]</a>
|
| 577 |
|
| 578 |
+
``` cpp
|
| 579 |
+
#define CHAR_BIT see below
|
| 580 |
+
#define SCHAR_MIN see below
|
| 581 |
+
#define SCHAR_MAX see below
|
| 582 |
+
#define UCHAR_MAX see below
|
| 583 |
+
#define CHAR_MIN see below
|
| 584 |
+
#define CHAR_MAX see below
|
| 585 |
+
#define MB_LEN_MAX see below
|
| 586 |
+
#define SHRT_MIN see below
|
| 587 |
+
#define SHRT_MAX see below
|
| 588 |
+
#define USHRT_MAX see below
|
| 589 |
+
#define INT_MIN see below
|
| 590 |
+
#define INT_MAX see below
|
| 591 |
+
#define UINT_MAX see below
|
| 592 |
+
#define LONG_MIN see below
|
| 593 |
+
#define LONG_MAX see below
|
| 594 |
+
#define ULONG_MAX see below
|
| 595 |
+
#define LLONG_MIN see below
|
| 596 |
+
#define LLONG_MAX see below
|
| 597 |
+
#define ULLONG_MAX see below
|
| 598 |
+
```
|
| 599 |
|
| 600 |
+
The header `<climits>` defines all macros the same as the C standard
|
| 601 |
+
library header `<limits.h>`.
|
|
|
|
| 602 |
|
| 603 |
+
[*Note 1*: The types of the constants defined by macros in `<climits>`
|
| 604 |
+
are not required to match the types to which the macros
|
| 605 |
+
refer. — *end note*]
|
| 606 |
|
| 607 |
+
ISO C 5.2.4.2.1
|
| 608 |
|
| 609 |
+
### Header `<cfloat>` synopsis <a id="cfloat.syn">[[cfloat.syn]]</a>
|
| 610 |
+
|
| 611 |
+
``` cpp
|
| 612 |
+
#define FLT_ROUNDS see below
|
| 613 |
+
#define FLT_EVAL_METHOD see below
|
| 614 |
+
#define FLT_HAS_SUBNORM see below
|
| 615 |
+
#define DBL_HAS_SUBNORM see below
|
| 616 |
+
#define LDBL_HAS_SUBNORM see below
|
| 617 |
+
#define FLT_RADIX see below
|
| 618 |
+
#define FLT_MANT_DIG see below
|
| 619 |
+
#define DBL_MANT_DIG see below
|
| 620 |
+
#define LDBL_MANT_DIG see below
|
| 621 |
+
#define FLT_DECIMAL_DIG see below
|
| 622 |
+
#define DBL_DECIMAL_DIG see below
|
| 623 |
+
#define LDBL_DECIMAL_DIG see below
|
| 624 |
+
#define DECIMAL_DIG see below
|
| 625 |
+
#define FLT_DIG see below
|
| 626 |
+
#define DBL_DIG see below
|
| 627 |
+
#define LDBL_DIG see below
|
| 628 |
+
#define FLT_MIN_EXP see below
|
| 629 |
+
#define DBL_MIN_EXP see below
|
| 630 |
+
#define LDBL_MIN_EXP see below
|
| 631 |
+
#define FLT_MIN_10_EXP see below
|
| 632 |
+
#define DBL_MIN_10_EXP see below
|
| 633 |
+
#define LDBL_MIN_10_EXP see below
|
| 634 |
+
#define FLT_MAX_EXP see below
|
| 635 |
+
#define DBL_MAX_EXP see below
|
| 636 |
+
#define LDBL_MAX_EXP see below
|
| 637 |
+
#define FLT_MAX_10_EXP see below
|
| 638 |
+
#define DBL_MAX_10_EXP see below
|
| 639 |
+
#define LDBL_MAX_10_EXP see below
|
| 640 |
+
#define FLT_MAX see below
|
| 641 |
+
#define DBL_MAX see below
|
| 642 |
+
#define LDBL_MAX see below
|
| 643 |
+
#define FLT_EPSILON see below
|
| 644 |
+
#define DBL_EPSILON see below
|
| 645 |
+
#define LDBL_EPSILON see below
|
| 646 |
+
#define FLT_MIN see below
|
| 647 |
+
#define DBL_MIN see below
|
| 648 |
+
#define LDBL_MIN see below
|
| 649 |
+
#define FLT_TRUE_MIN see below
|
| 650 |
+
#define DBL_TRUE_MIN see below
|
| 651 |
+
#define LDBL_TRUE_MIN see below
|
| 652 |
+
```
|
| 653 |
+
|
| 654 |
+
The header `<cfloat>` defines all macros the same as the C standard
|
| 655 |
+
library header `<float.h>`.
|
| 656 |
+
|
| 657 |
+
ISO C 5.2.4.2.2
|
| 658 |
|