|
306 | 306 |
|
307 | 307 | \rSec1[support.limits]{Implementation properties}
|
308 | 308 |
|
309 |
| -\rSec2[support.limits.general]{In general} |
| 309 | +\rSec2[support.limits.general]{General} |
310 | 310 |
|
311 | 311 | \pnum
|
312 | 312 | The headers
|
313 |
| -\tcode{<limits>}~(\ref{limits}), |
| 313 | +\tcode{<limits>}~(\ref{limits.syn}), |
314 | 314 | \tcode{<climits>}~(\ref{climits.syn}), and
|
315 | 315 | \tcode{<cfloat>}~(\ref{cfloat.syn})
|
316 | 316 | supply characteristics of implementation-dependent
|
317 | 317 | arithmetic types~(\ref{basic.fundamental}).
|
318 | 318 |
|
319 |
| -\rSec2[limits]{Numeric limits} |
320 |
| - |
321 |
| -\rSec3[limits.numeric]{Class template \tcode{numeric_limits}} |
322 |
| - |
323 |
| -\pnum |
324 |
| -The |
325 |
| -\indexlibrary{\idxcode{numeric_limits}}% |
326 |
| -\tcode{numeric_limits} |
327 |
| -class template provides a \Cpp program with information about various properties of |
328 |
| -the implementation's representation of the |
329 |
| -arithmetic types. |
330 |
| - |
331 |
| -\pnum |
332 |
| -Specializations shall be provided for each |
333 |
| -arithmetic type, |
334 |
| -both floating-point and integer, including |
335 |
| -\tcode{bool}. |
336 |
| -The member |
337 |
| -\tcode{is_specialized} |
338 |
| -shall be |
339 |
| -\tcode{true} |
340 |
| -for all such specializations of |
341 |
| -\tcode{numeric_limits}. |
342 |
| - |
343 |
| -\pnum |
344 |
| -For all members declared |
345 |
| -\tcode{static} \tcode{constexpr} |
346 |
| -in the |
347 |
| -\tcode{numeric_limits} |
348 |
| -template, specializations shall define these values in such a way |
349 |
| -that they are usable as |
350 |
| -constant expressions. |
351 |
| - |
352 |
| -\pnum |
353 |
| -Non-arithmetic standard types, such as |
354 |
| -\tcode{complex<T>}~(\ref{complex}), shall not have specializations. |
355 |
| - |
356 |
| -\rSec3[limits.syn]{Header \tcode{<limits>} synopsis} |
| 319 | +\rSec2[limits.syn]{Header \tcode{<limits>} synopsis} |
357 | 320 | \indextext{\idxhdr{limits}}%
|
358 | 321 | \indexlibrary{\idxhdr{limits}}%
|
359 | 322 | \indextext{\idxcode{numeric_limits}}%
|
|
363 | 326 |
|
364 | 327 | \begin{codeblock}
|
365 | 328 | namespace std {
|
366 |
| - template<class T> class numeric_limits; |
| 329 | + // \ref{fp.style}, floating-point type properties |
367 | 330 | enum float_round_style;
|
368 | 331 | enum float_denorm_style;
|
369 | 332 |
|
| 333 | + // \ref{numeric.limits}, class template numeric_limits |
| 334 | + template<class T> class numeric_limits; |
| 335 | + |
370 | 336 | template<> class numeric_limits<bool>;
|
371 | 337 |
|
372 | 338 | template<> class numeric_limits<char>;
|
|
391 | 357 | }
|
392 | 358 | \end{codeblock}
|
393 | 359 |
|
394 |
| -\rSec3[numeric.limits]{Class template \tcode{numeric_limits}} |
| 360 | +\rSec2[fp.style]{Floating-point type properties} |
| 361 | + |
| 362 | +\rSec3[round.style]{Type \tcode{float_round_style}} |
| 363 | + |
| 364 | +\indexlibrary{\idxcode{float_round_style}}% |
| 365 | +\begin{codeblock} |
| 366 | +namespace std { |
| 367 | + enum float_round_style { |
| 368 | + round_indeterminate = -1, |
| 369 | + round_toward_zero = 0, |
| 370 | + round_to_nearest = 1, |
| 371 | + round_toward_infinity = 2, |
| 372 | + round_toward_neg_infinity = 3 |
| 373 | + }; |
| 374 | +} |
| 375 | +\end{codeblock} |
| 376 | + |
| 377 | +\pnum |
| 378 | +The rounding mode for floating-point arithmetic is characterized by the |
| 379 | +values: |
| 380 | + |
| 381 | +\begin{itemize} |
| 382 | +\item |
| 383 | +\indexlibrary{\idxcode{round_indeterminate}}% |
| 384 | +\tcode{round_indeterminate} |
| 385 | +if the rounding style is indeterminable |
| 386 | +\item |
| 387 | +\indexlibrary{\idxcode{round_toward_zero}}% |
| 388 | +\tcode{round_toward_zero} |
| 389 | +if the rounding style is toward zero |
| 390 | +\item |
| 391 | +\indexlibrary{\idxcode{round_to_nearest}}% |
| 392 | +\tcode{round_to_nearest} |
| 393 | +if the rounding style is to the nearest representable value |
| 394 | +\item |
| 395 | +\indexlibrary{\idxcode{round_toward_infinity}}% |
| 396 | +\tcode{round_toward_infinity} |
| 397 | +if the rounding style is toward infinity |
| 398 | +\item |
| 399 | +\indexlibrary{\idxcode{round_toward_neg_infinity}}% |
| 400 | +\tcode{round_toward_neg_infinity} |
| 401 | +if the rounding style is toward negative infinity |
| 402 | +\end{itemize} |
| 403 | + |
| 404 | +\rSec3[denorm.style]{Type \tcode{float_denorm_style}} |
| 405 | + |
| 406 | +\indexlibrary{\idxcode{float_denorm_style}}% |
| 407 | +\begin{codeblock} |
| 408 | +namespace std { |
| 409 | + enum float_denorm_style { |
| 410 | + denorm_indeterminate = -1, |
| 411 | + denorm_absent = 0, |
| 412 | + denorm_present = 1 |
| 413 | + }; |
| 414 | +} |
| 415 | +\end{codeblock} |
| 416 | + |
| 417 | +\indextext{denormalized value|see{number, subnormal}}% |
| 418 | +\indextext{value!denormalized|see{number, subnormal}}% |
| 419 | +\indextext{subnormal number|see{number, subnormal}}% |
| 420 | +\indextext{number!subnormal}% |
| 421 | +\pnum |
| 422 | +The presence or absence of subnormal numbers (variable number of exponent bits) |
| 423 | +is characterized by the values: |
| 424 | + |
| 425 | +\begin{itemize} |
| 426 | +\item |
| 427 | +\indexlibrary{\idxcode{denorm_indeterminate}}% |
| 428 | +\tcode{denorm_indeterminate} |
| 429 | +if it cannot be determined whether or not the type allows subnormal values |
| 430 | +\item |
| 431 | +\indexlibrary{\idxcode{denorm_absent}}% |
| 432 | +\tcode{denorm_absent} |
| 433 | +if the type does not allow subnormal values |
| 434 | +\item |
| 435 | +\indexlibrary{\idxcode{denorm_present}}% |
| 436 | +\tcode{denorm_present} |
| 437 | +if the type does allow subnormal values |
| 438 | +\end{itemize} |
| 439 | + |
| 440 | +\rSec2[numeric.limits]{Class template \tcode{numeric_limits}} |
| 441 | + |
| 442 | +\pnum |
| 443 | +The |
| 444 | +\indexlibrary{\idxcode{numeric_limits}}% |
| 445 | +\tcode{numeric_limits} |
| 446 | +class template provides a \Cpp program with information about various properties of |
| 447 | +the implementation's representation of the |
| 448 | +arithmetic types. |
395 | 449 |
|
396 | 450 | \indexlibrary{\idxcode{numeric_limits}}%
|
397 | 451 | \begin{codeblock}
|
|
443 | 497 | }
|
444 | 498 | \end{codeblock}
|
445 | 499 |
|
| 500 | +\pnum |
| 501 | +For all members declared |
| 502 | +\tcode{static} \tcode{constexpr} |
| 503 | +in the |
| 504 | +\tcode{numeric_limits} |
| 505 | +template, specializations shall define these values in such a way |
| 506 | +that they are usable as |
| 507 | +constant expressions. |
| 508 | + |
446 | 509 | \pnum
|
447 | 510 | The default
|
448 | 511 | \tcode{numeric_limits<T>}
|
449 | 512 | template shall have all members, but with 0 or
|
450 | 513 | \tcode{false}
|
451 | 514 | values.
|
452 | 515 |
|
| 516 | +\pnum |
| 517 | +Specializations shall be provided for each |
| 518 | +arithmetic type, |
| 519 | +both floating-point and integer, including |
| 520 | +\tcode{bool}. |
| 521 | +The member |
| 522 | +\tcode{is_specialized} |
| 523 | +shall be |
| 524 | +\tcode{true} |
| 525 | +for all such specializations of |
| 526 | +\tcode{numeric_limits}. |
| 527 | + |
453 | 528 | \pnum
|
454 | 529 | The value of each member of a specialization of
|
455 | 530 | \tcode{numeric_limits} on a cv-qualified type
|
456 | 531 | \tcode{cv T} shall be equal to the value of the corresponding member of
|
457 | 532 | the specialization on the unqualified type \tcode{T}.
|
458 | 533 |
|
| 534 | +\pnum |
| 535 | +Non-arithmetic standard types, such as |
| 536 | +\tcode{complex<T>}~(\ref{complex}), shall not have specializations. |
| 537 | + |
459 | 538 | \rSec3[numeric.limits.members]{\tcode{numeric_limits} members}
|
460 | 539 |
|
461 | 540 | \indexlibrarymember{min}{numeric_limits}%
|
|
969 | 1048 | \tcode{round_toward_zero}.
|
970 | 1049 | \end{itemdescr}
|
971 | 1050 |
|
972 |
| -\rSec3[round.style]{Type \tcode{float_round_style}} |
973 |
| - |
974 |
| -\indexlibrary{\idxcode{float_round_style}}% |
975 |
| -\begin{codeblock} |
976 |
| -namespace std { |
977 |
| - enum float_round_style { |
978 |
| - round_indeterminate = -1, |
979 |
| - round_toward_zero = 0, |
980 |
| - round_to_nearest = 1, |
981 |
| - round_toward_infinity = 2, |
982 |
| - round_toward_neg_infinity = 3 |
983 |
| - }; |
984 |
| -} |
985 |
| -\end{codeblock} |
986 |
| - |
987 |
| -\pnum |
988 |
| -The rounding mode for floating-point arithmetic is characterized by the |
989 |
| -values: |
990 |
| - |
991 |
| -\begin{itemize} |
992 |
| -\item |
993 |
| -\indexlibrary{\idxcode{round_indeterminate}}% |
994 |
| -\tcode{round_indeterminate} |
995 |
| -if the rounding style is indeterminable |
996 |
| -\item |
997 |
| -\indexlibrary{\idxcode{round_toward_zero}}% |
998 |
| -\tcode{round_toward_zero} |
999 |
| -if the rounding style is toward zero |
1000 |
| -\item |
1001 |
| -\indexlibrary{\idxcode{round_to_nearest}}% |
1002 |
| -\tcode{round_to_nearest} |
1003 |
| -if the rounding style is to the nearest representable value |
1004 |
| -\item |
1005 |
| -\indexlibrary{\idxcode{round_toward_infinity}}% |
1006 |
| -\tcode{round_toward_infinity} |
1007 |
| -if the rounding style is toward infinity |
1008 |
| -\item |
1009 |
| -\indexlibrary{\idxcode{round_toward_neg_infinity}}% |
1010 |
| -\tcode{round_toward_neg_infinity} |
1011 |
| -if the rounding style is toward negative infinity |
1012 |
| -\end{itemize} |
1013 |
| - |
1014 |
| -\rSec3[denorm.style]{Type \tcode{float_denorm_style}} |
1015 |
| - |
1016 |
| -\indexlibrary{\idxcode{float_denorm_style}}% |
1017 |
| -\begin{codeblock} |
1018 |
| -namespace std { |
1019 |
| - enum float_denorm_style { |
1020 |
| - denorm_indeterminate = -1, |
1021 |
| - denorm_absent = 0, |
1022 |
| - denorm_present = 1 |
1023 |
| - }; |
1024 |
| -} |
1025 |
| -\end{codeblock} |
1026 |
| - |
1027 |
| -\indextext{denormalized value|see{number, subnormal}}% |
1028 |
| -\indextext{value!denormalized|see{number, subnormal}}% |
1029 |
| -\indextext{subnormal number|see{number, subnormal}}% |
1030 |
| -\indextext{number!subnormal}% |
1031 |
| -\pnum |
1032 |
| -The presence or absence of subnormal numbers (variable number of exponent bits) |
1033 |
| -is characterized by the values: |
1034 |
| - |
1035 |
| -\begin{itemize} |
1036 |
| -\item |
1037 |
| -\indexlibrary{\idxcode{denorm_indeterminate}}% |
1038 |
| -\tcode{denorm_indeterminate} |
1039 |
| -if it cannot be determined whether or not the type allows subnormal values |
1040 |
| -\item |
1041 |
| -\indexlibrary{\idxcode{denorm_absent}}% |
1042 |
| -\tcode{denorm_absent} |
1043 |
| -if the type does not allow subnormal values |
1044 |
| -\item |
1045 |
| -\indexlibrary{\idxcode{denorm_present}}% |
1046 |
| -\tcode{denorm_present} |
1047 |
| -if the type does allow subnormal values |
1048 |
| -\end{itemize} |
1049 |
| - |
1050 | 1051 | \rSec3[numeric.special]{\tcode{numeric_limits} specializations}
|
1051 | 1052 |
|
1052 | 1053 | \pnum
|
|
1165 | 1166 | }
|
1166 | 1167 | \end{codeblock}
|
1167 | 1168 |
|
1168 |
| -\rSec2[c.limits]{C library} |
1169 |
| - |
1170 |
| -\rSec3[climits.syn]{Header \tcode{<climits>} synopsis} |
| 1169 | +\rSec2[climits.syn]{Header \tcode{<climits>} synopsis} |
1171 | 1170 |
|
1172 | 1171 | \indexlibrary{\idxcode{CHAR_BIT}}%
|
1173 | 1172 | \indexlibrary{\idxcode{SCHAR_MIN}}%
|
|
1220 | 1219 |
|
1221 | 1220 | \xref ISO C 5.2.4.2.1
|
1222 | 1221 |
|
1223 |
| -\rSec3[cfloat.syn]{Header \tcode{<cfloat>} synopsis} |
| 1222 | +\rSec2[cfloat.syn]{Header \tcode{<cfloat>} synopsis} |
1224 | 1223 |
|
1225 | 1224 | \indexlibrary{\idxcode{DBL_DECIMAL_DIG}}%
|
1226 | 1225 | \indexlibrary{\idxcode{DBL_DIG}}%
|
|
0 commit comments