Files
2025-10-25 03:02:53 +03:00

38 lines
4.0 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[numeric.special]
# 17 Language support library [[support]](./#support)
## 17.3 Implementation properties [[support.limits]](support.limits#numeric.special)
### 17.3.5 Class template numeric_limits [[numeric.limits]](numeric.limits#numeric.special)
#### 17.3.5.3 numeric_limits specializations [numeric.special]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1657)
All members shall be provided for all specializations[.](#1.sentence-1)
However, many values are only required to be meaningful under certain
conditions
(for example,epsilon() is only meaningful ifis_integer isfalse)[.](#1.sentence-2)
Any value that is not “meaningful” shall be set to 0 orfalse[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1670)
[*Example [1](#example-1)*: namespace std {template<> class numeric_limits<float> {public:static constexpr bool is_specialized = true; static constexpr float min() noexcept { return 1.17549435E-38F; }static constexpr float max() noexcept { return 3.40282347E+38F; }static constexpr float lowest() noexcept { return -3.40282347E+38F; }static constexpr int digits = 24; static constexpr int digits10 = 6; static constexpr int max_digits10 = 9; static constexpr bool is_signed = true; static constexpr bool is_integer = false; static constexpr bool is_exact = false; static constexpr int radix = 2; static constexpr float epsilon() noexcept { return 1.19209290E-07F; }static constexpr float round_error() noexcept { return 0.5F; }static constexpr int min_exponent = -125; static constexpr int min_exponent10 = - 37; static constexpr int max_exponent = +128; static constexpr int max_exponent10 = + 38; static constexpr bool has_infinity = true; static constexpr bool has_quiet_NaN = true; static constexpr bool has_signaling_NaN = true; static constexpr float infinity() noexcept { return *value*; }static constexpr float quiet_NaN() noexcept { return *value*; }static constexpr float signaling_NaN() noexcept { return *value*; }static constexpr float denorm_min() noexcept { return min(); }static constexpr bool is_iec559 = true; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = true; static constexpr float_round_style round_style = round_to_nearest; };} — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1720)
The specialization forbool shall be provided as follows:
[🔗](#lib:numeric_limits%3cbool%3e)
namespace std {template<> class numeric_limits<bool> {public:static constexpr bool is_specialized = true; static constexpr bool min() noexcept { return false; }static constexpr bool max() noexcept { return true; }static constexpr bool lowest() noexcept { return false; }static constexpr int digits = 1; static constexpr int digits10 = 0; static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr bool epsilon() noexcept { return 0; }static constexpr bool round_error() noexcept { return 0; }static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr bool infinity() noexcept { return 0; }static constexpr bool quiet_NaN() noexcept { return 0; }static constexpr bool signaling_NaN() noexcept { return 0; }static constexpr bool denorm_min() noexcept { return 0; }static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = false; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; };}