tmp/tmp_pbwu7ut/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
### Class template `numeric_limits` <a id="numeric.limits">[[numeric.limits]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
The `numeric_limits` class template provides a C++ program with
|
| 4 |
information about various properties of the implementation’s
|
| 5 |
representation of the arithmetic types.
|
| 6 |
|
| 7 |
``` cpp
|
|
@@ -29,12 +31,10 @@ namespace std {
|
|
| 29 |
static constexpr int max_exponent10 = 0;
|
| 30 |
|
| 31 |
static constexpr bool has_infinity = false;
|
| 32 |
static constexpr bool has_quiet_NaN = false;
|
| 33 |
static constexpr bool has_signaling_NaN = false;
|
| 34 |
-
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 35 |
-
static constexpr bool has_denorm_loss = false;
|
| 36 |
static constexpr T infinity() noexcept { return T(); }
|
| 37 |
static constexpr T quiet_NaN() noexcept { return T(); }
|
| 38 |
static constexpr T signaling_NaN() noexcept { return T(); }
|
| 39 |
static constexpr T denorm_min() noexcept { return T(); }
|
| 40 |
|
|
@@ -51,12 +51,16 @@ namespace std {
|
|
| 51 |
|
| 52 |
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 53 |
template, specializations shall define these values in such a way that
|
| 54 |
they are usable as constant expressions.
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
Specializations shall be provided for each arithmetic type, both
|
| 60 |
floating-point and integer, including `bool`. The member
|
| 61 |
`is_specialized` shall be `true` for all such specializations of
|
| 62 |
`numeric_limits`.
|
|
@@ -248,96 +252,82 @@ Number”.[^17]
|
|
| 248 |
|
| 249 |
Meaningful for all floating-point types.
|
| 250 |
|
| 251 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 252 |
|
| 253 |
-
``` cpp
|
| 254 |
-
static constexpr float_denorm_style has_denorm;
|
| 255 |
-
```
|
| 256 |
-
|
| 257 |
-
`denorm_present` if the type allows subnormal values (variable number of
|
| 258 |
-
exponent bits)[^18], `denorm_absent` if the type does not allow
|
| 259 |
-
subnormal values, and `denorm_indeterminate` if it is indeterminate at
|
| 260 |
-
compile time whether the type allows subnormal values.
|
| 261 |
-
|
| 262 |
-
Meaningful for all floating-point types.
|
| 263 |
-
|
| 264 |
-
``` cpp
|
| 265 |
-
static constexpr bool has_denorm_loss;
|
| 266 |
-
```
|
| 267 |
-
|
| 268 |
-
`true` if loss of accuracy is detected as a denormalization loss, rather
|
| 269 |
-
than as an inexact result.[^19]
|
| 270 |
-
|
| 271 |
``` cpp
|
| 272 |
static constexpr T infinity() noexcept;
|
| 273 |
```
|
| 274 |
|
| 275 |
-
Representation of positive infinity, if available.[^
|
| 276 |
|
| 277 |
Meaningful for all specializations for which `has_infinity != false`.
|
| 278 |
Required in specializations for which `is_iec559 != false`.
|
| 279 |
|
| 280 |
``` cpp
|
| 281 |
static constexpr T quiet_NaN() noexcept;
|
| 282 |
```
|
| 283 |
|
| 284 |
-
Representation of a quiet “Not a Number”, if available.[^
|
| 285 |
|
| 286 |
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 287 |
Required in specializations for which `is_iec559 != false`.
|
| 288 |
|
| 289 |
``` cpp
|
| 290 |
static constexpr T signaling_NaN() noexcept;
|
| 291 |
```
|
| 292 |
|
| 293 |
-
Representation of a signaling “Not a Number”, if available.[^
|
| 294 |
|
| 295 |
Meaningful for all specializations for which
|
| 296 |
`has_signaling_NaN != false`. Required in specializations for which
|
| 297 |
`is_iec559 != false`.
|
| 298 |
|
| 299 |
``` cpp
|
| 300 |
static constexpr T denorm_min() noexcept;
|
| 301 |
```
|
| 302 |
|
| 303 |
-
Minimum positive subnormal value.[^
|
|
|
|
|
|
|
| 304 |
|
| 305 |
Meaningful for all floating-point types.
|
| 306 |
|
| 307 |
-
In specializations for which `has_denorm == false`, returns the minimum
|
| 308 |
-
positive normalized value.
|
| 309 |
-
|
| 310 |
``` cpp
|
| 311 |
static constexpr bool is_iec559;
|
| 312 |
```
|
| 313 |
|
| 314 |
-
`true` if and only if the type adheres to ISO/IEC/IEEE 60559.[^
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
Meaningful for all floating-point types.
|
| 317 |
|
| 318 |
``` cpp
|
| 319 |
static constexpr bool is_bounded;
|
| 320 |
```
|
| 321 |
|
| 322 |
-
`true` if the set of values representable by the type is finite.[^
|
| 323 |
|
| 324 |
-
[*Note
|
| 325 |
This member would be `false` for arbitrary precision
|
| 326 |
types. — *end note*]
|
| 327 |
|
| 328 |
Meaningful for all specializations.
|
| 329 |
|
| 330 |
``` cpp
|
| 331 |
static constexpr bool is_modulo;
|
| 332 |
```
|
| 333 |
|
| 334 |
-
`true` if the type is modulo.[^
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
`max()
|
|
|
|
| 339 |
|
| 340 |
[*Example 1*: `is_modulo` is `false` for signed integer
|
| 341 |
types [[basic.fundamental]] unless an implementation, as an extension to
|
| 342 |
this document, defines signed integer overflow to
|
| 343 |
wrap. — *end example*]
|
|
@@ -347,27 +337,27 @@ Meaningful for all specializations.
|
|
| 347 |
``` cpp
|
| 348 |
static constexpr bool traps;
|
| 349 |
```
|
| 350 |
|
| 351 |
`true` if, at the start of the program, there exists a value of the type
|
| 352 |
-
that would cause an arithmetic operation using that value to trap.[^
|
| 353 |
|
| 354 |
Meaningful for all specializations.
|
| 355 |
|
| 356 |
``` cpp
|
| 357 |
static constexpr bool tinyness_before;
|
| 358 |
```
|
| 359 |
|
| 360 |
-
`true` if tinyness is detected before rounding.[^
|
| 361 |
|
| 362 |
Meaningful for all floating-point types.
|
| 363 |
|
| 364 |
``` cpp
|
| 365 |
static constexpr float_round_style round_style;
|
| 366 |
```
|
| 367 |
|
| 368 |
-
The rounding style for the type.[^
|
| 369 |
|
| 370 |
Meaningful for all floating-point types. Specializations for integer
|
| 371 |
types shall return `round_toward_zero`.
|
| 372 |
|
| 373 |
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
|
@@ -407,12 +397,10 @@ namespace std {
|
|
| 407 |
static constexpr int max_exponent10 = + 38;
|
| 408 |
|
| 409 |
static constexpr bool has_infinity = true;
|
| 410 |
static constexpr bool has_quiet_NaN = true;
|
| 411 |
static constexpr bool has_signaling_NaN = true;
|
| 412 |
-
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 413 |
-
static constexpr bool has_denorm_loss = false;
|
| 414 |
|
| 415 |
static constexpr float infinity() noexcept { return value; }
|
| 416 |
static constexpr float quiet_NaN() noexcept { return value; }
|
| 417 |
static constexpr float signaling_NaN() noexcept { return value; }
|
| 418 |
static constexpr float denorm_min() noexcept { return min(); }
|
|
@@ -458,12 +446,10 @@ namespace std {
|
|
| 458 |
static constexpr int max_exponent10 = 0;
|
| 459 |
|
| 460 |
static constexpr bool has_infinity = false;
|
| 461 |
static constexpr bool has_quiet_NaN = false;
|
| 462 |
static constexpr bool has_signaling_NaN = false;
|
| 463 |
-
static constexpr float_denorm_style has_denorm = denorm_absent;
|
| 464 |
-
static constexpr bool has_denorm_loss = false;
|
| 465 |
static constexpr bool infinity() noexcept { return 0; }
|
| 466 |
static constexpr bool quiet_NaN() noexcept { return 0; }
|
| 467 |
static constexpr bool signaling_NaN() noexcept { return 0; }
|
| 468 |
static constexpr bool denorm_min() noexcept { return 0; }
|
| 469 |
|
|
|
|
| 1 |
### Class template `numeric_limits` <a id="numeric.limits">[[numeric.limits]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="numeric.limits.general">[[numeric.limits.general]]</a>
|
| 4 |
+
|
| 5 |
The `numeric_limits` class template provides a C++ program with
|
| 6 |
information about various properties of the implementation’s
|
| 7 |
representation of the arithmetic types.
|
| 8 |
|
| 9 |
``` cpp
|
|
|
|
| 31 |
static constexpr int max_exponent10 = 0;
|
| 32 |
|
| 33 |
static constexpr bool has_infinity = false;
|
| 34 |
static constexpr bool has_quiet_NaN = false;
|
| 35 |
static constexpr bool has_signaling_NaN = false;
|
|
|
|
|
|
|
| 36 |
static constexpr T infinity() noexcept { return T(); }
|
| 37 |
static constexpr T quiet_NaN() noexcept { return T(); }
|
| 38 |
static constexpr T signaling_NaN() noexcept { return T(); }
|
| 39 |
static constexpr T denorm_min() noexcept { return T(); }
|
| 40 |
|
|
|
|
| 51 |
|
| 52 |
For all members declared `static` `constexpr` in the `numeric_limits`
|
| 53 |
template, specializations shall define these values in such a way that
|
| 54 |
they are usable as constant expressions.
|
| 55 |
|
| 56 |
+
For the `numeric_limits` primary template, all data members are
|
| 57 |
+
value-initialized and all member functions return a value-initialized
|
| 58 |
+
object.
|
| 59 |
+
|
| 60 |
+
[*Note 1*: This means all members have zero or `false` values unless
|
| 61 |
+
`numeric_limits` is specialized for a type. — *end note*]
|
| 62 |
|
| 63 |
Specializations shall be provided for each arithmetic type, both
|
| 64 |
floating-point and integer, including `bool`. The member
|
| 65 |
`is_specialized` shall be `true` for all such specializations of
|
| 66 |
`numeric_limits`.
|
|
|
|
| 252 |
|
| 253 |
Meaningful for all floating-point types.
|
| 254 |
|
| 255 |
Shall be `true` for all specializations in which `is_iec559 != false`.
|
| 256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
``` cpp
|
| 258 |
static constexpr T infinity() noexcept;
|
| 259 |
```
|
| 260 |
|
| 261 |
+
Representation of positive infinity, if available.[^18]
|
| 262 |
|
| 263 |
Meaningful for all specializations for which `has_infinity != false`.
|
| 264 |
Required in specializations for which `is_iec559 != false`.
|
| 265 |
|
| 266 |
``` cpp
|
| 267 |
static constexpr T quiet_NaN() noexcept;
|
| 268 |
```
|
| 269 |
|
| 270 |
+
Representation of a quiet “Not a Number”, if available.[^19]
|
| 271 |
|
| 272 |
Meaningful for all specializations for which `has_quiet_NaN != false`.
|
| 273 |
Required in specializations for which `is_iec559 != false`.
|
| 274 |
|
| 275 |
``` cpp
|
| 276 |
static constexpr T signaling_NaN() noexcept;
|
| 277 |
```
|
| 278 |
|
| 279 |
+
Representation of a signaling “Not a Number”, if available.[^20]
|
| 280 |
|
| 281 |
Meaningful for all specializations for which
|
| 282 |
`has_signaling_NaN != false`. Required in specializations for which
|
| 283 |
`is_iec559 != false`.
|
| 284 |
|
| 285 |
``` cpp
|
| 286 |
static constexpr T denorm_min() noexcept;
|
| 287 |
```
|
| 288 |
|
| 289 |
+
Minimum positive subnormal value, if available.[^21]
|
| 290 |
+
|
| 291 |
+
Otherwise, minimum positive normalized value.
|
| 292 |
|
| 293 |
Meaningful for all floating-point types.
|
| 294 |
|
|
|
|
|
|
|
|
|
|
| 295 |
``` cpp
|
| 296 |
static constexpr bool is_iec559;
|
| 297 |
```
|
| 298 |
|
| 299 |
+
`true` if and only if the type adheres to ISO/IEC/IEEE 60559.[^22]
|
| 300 |
+
|
| 301 |
+
[*Note 1*: The value is `true` for any of the types `float16_t`,
|
| 302 |
+
`float32_t`, `float64_t`, or `float128_t`, if
|
| 303 |
+
present [[basic.extended.fp]]. — *end note*]
|
| 304 |
|
| 305 |
Meaningful for all floating-point types.
|
| 306 |
|
| 307 |
``` cpp
|
| 308 |
static constexpr bool is_bounded;
|
| 309 |
```
|
| 310 |
|
| 311 |
+
`true` if the set of values representable by the type is finite.[^23]
|
| 312 |
|
| 313 |
+
[*Note 2*: All fundamental types [[basic.fundamental]] are bounded.
|
| 314 |
This member would be `false` for arbitrary precision
|
| 315 |
types. — *end note*]
|
| 316 |
|
| 317 |
Meaningful for all specializations.
|
| 318 |
|
| 319 |
``` cpp
|
| 320 |
static constexpr bool is_modulo;
|
| 321 |
```
|
| 322 |
|
| 323 |
+
`true` if the type is modulo.[^24]
|
| 324 |
+
|
| 325 |
+
A type is modulo if, for any operation involving `+`, `-`, or `*` on
|
| 326 |
+
values of that type whose result would fall outside the range \[`min()`,
|
| 327 |
+
`max()`\], the value returned differs from the true value by an integer
|
| 328 |
+
multiple of `max() - min() + 1`.
|
| 329 |
|
| 330 |
[*Example 1*: `is_modulo` is `false` for signed integer
|
| 331 |
types [[basic.fundamental]] unless an implementation, as an extension to
|
| 332 |
this document, defines signed integer overflow to
|
| 333 |
wrap. — *end example*]
|
|
|
|
| 337 |
``` cpp
|
| 338 |
static constexpr bool traps;
|
| 339 |
```
|
| 340 |
|
| 341 |
`true` if, at the start of the program, there exists a value of the type
|
| 342 |
+
that would cause an arithmetic operation using that value to trap.[^25]
|
| 343 |
|
| 344 |
Meaningful for all specializations.
|
| 345 |
|
| 346 |
``` cpp
|
| 347 |
static constexpr bool tinyness_before;
|
| 348 |
```
|
| 349 |
|
| 350 |
+
`true` if tinyness is detected before rounding.[^26]
|
| 351 |
|
| 352 |
Meaningful for all floating-point types.
|
| 353 |
|
| 354 |
``` cpp
|
| 355 |
static constexpr float_round_style round_style;
|
| 356 |
```
|
| 357 |
|
| 358 |
+
The rounding style for the type.[^27]
|
| 359 |
|
| 360 |
Meaningful for all floating-point types. Specializations for integer
|
| 361 |
types shall return `round_toward_zero`.
|
| 362 |
|
| 363 |
#### `numeric_limits` specializations <a id="numeric.special">[[numeric.special]]</a>
|
|
|
|
| 397 |
static constexpr int max_exponent10 = + 38;
|
| 398 |
|
| 399 |
static constexpr bool has_infinity = true;
|
| 400 |
static constexpr bool has_quiet_NaN = true;
|
| 401 |
static constexpr bool has_signaling_NaN = true;
|
|
|
|
|
|
|
| 402 |
|
| 403 |
static constexpr float infinity() noexcept { return value; }
|
| 404 |
static constexpr float quiet_NaN() noexcept { return value; }
|
| 405 |
static constexpr float signaling_NaN() noexcept { return value; }
|
| 406 |
static constexpr float denorm_min() noexcept { return min(); }
|
|
|
|
| 446 |
static constexpr int max_exponent10 = 0;
|
| 447 |
|
| 448 |
static constexpr bool has_infinity = false;
|
| 449 |
static constexpr bool has_quiet_NaN = false;
|
| 450 |
static constexpr bool has_signaling_NaN = false;
|
|
|
|
|
|
|
| 451 |
static constexpr bool infinity() noexcept { return 0; }
|
| 452 |
static constexpr bool quiet_NaN() noexcept { return 0; }
|
| 453 |
static constexpr bool signaling_NaN() noexcept { return 0; }
|
| 454 |
static constexpr bool denorm_min() noexcept { return 0; }
|
| 455 |
|