804 lines
31 KiB
Markdown
804 lines
31 KiB
Markdown
[numeric.limits]
|
||
|
||
# 17 Language support library [[support]](./#support)
|
||
|
||
## 17.3 Implementation properties [[support.limits]](support.limits#numeric.limits)
|
||
|
||
### 17.3.5 Class template numeric_limits [numeric.limits]
|
||
|
||
#### [17.3.5.1](#general) General [[numeric.limits.general]](numeric.limits.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L998)
|
||
|
||
Thenumeric_limits class template provides a C++ program with information about various properties of
|
||
the implementation's representation of the
|
||
arithmetic types[.](#general-1.sentence-1)
|
||
|
||
[ð](#lib:numeric_limits_)
|
||
|
||
namespace std {template<class T> class numeric_limits {public:static constexpr bool is_specialized = false; static constexpr T min() noexcept { return T(); }static constexpr T max() noexcept { return T(); }static constexpr T lowest() noexcept { return T(); }static constexpr int digits = 0; static constexpr int digits10 = 0; static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = false; static constexpr bool is_exact = false; static constexpr int radix = 0; static constexpr T epsilon() noexcept { return T(); }static constexpr T round_error() noexcept { return T(); }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 T infinity() noexcept { return T(); }static constexpr T quiet_NaN() noexcept { return T(); }static constexpr T signaling_NaN() noexcept { return T(); }static constexpr T denorm_min() noexcept { return T(); }static constexpr bool is_iec559 = false; static constexpr bool is_bounded = false; 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; };}
|
||
|
||
[2](#general-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1050)
|
||
|
||
For all members declaredstatic constexpr in thenumeric_limits template, specializations shall define these values in such a way
|
||
that they are usable as
|
||
constant expressions[.](#general-2.sentence-1)
|
||
|
||
[3](#general-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1059)
|
||
|
||
For thenumeric_limits primary template, all data members are value-initialized and all
|
||
member functions return a value-initialized object[.](#general-3.sentence-1)
|
||
|
||
[*Note [1](#general-note-1)*:
|
||
|
||
This means all members have zero or false values
|
||
unless numeric_limits is specialized for a type[.](#general-3.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[4](#general-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1069)
|
||
|
||
Specializations shall be provided for each
|
||
arithmetic type,
|
||
both floating-point and integer, includingbool[.](#general-4.sentence-1)
|
||
|
||
The memberis_specialized shall betrue for all such specializations ofnumeric_limits[.](#general-4.sentence-2)
|
||
|
||
[5](#general-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1081)
|
||
|
||
The value of each member of a specialization ofnumeric_limits on a cv-qualified typecv T shall be equal to the value of the corresponding member of
|
||
the specialization on the unqualified type T[.](#general-5.sentence-1)
|
||
|
||
[6](#general-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1087)
|
||
|
||
Non-arithmetic standard types, such as[complex<T>](complex "29.4.3 Class template complex [complex]"), shall not have specializations[.](#general-6.sentence-1)
|
||
|
||
#### [17.3.5.2](#members) numeric_limits members [[numeric.limits.members]](numeric.limits.members)
|
||
|
||
[1](#members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1093)
|
||
|
||
Each member function defined in this subclause is signal-safe ([[support.signal]](support.signal "17.14.5 Signal handlers"))[.](#members-1.sentence-1)
|
||
|
||
[*Note [1](#members-note-1)*:
|
||
|
||
The arithmetic specification described in ISO/IEC 10967-1:2012 is
|
||
commonly termed LIA-1[.](#members-1.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:min,numeric_limits)
|
||
|
||
`static constexpr T min() noexcept;
|
||
`
|
||
|
||
[2](#members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1108)
|
||
|
||
Minimum finite value[.](#members-2.sentence-1)[161](#footnote-161 "Equivalent to CHAR_MIN, SHRT_MIN, FLT_MIN, DBL_MIN, etc.")
|
||
|
||
[3](#members-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1116)
|
||
|
||
For floating-point types with subnormal numbers, returns the minimum positive
|
||
normalized value[.](#members-3.sentence-1)
|
||
|
||
[4](#members-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1120)
|
||
|
||
Meaningful for all specializations in whichis_bounded != false,
|
||
oris_bounded == false && is_signed == false[.](#members-4.sentence-1)
|
||
|
||
[ð](#lib:max,numeric_limits)
|
||
|
||
`static constexpr T max() noexcept;
|
||
`
|
||
|
||
[5](#members-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1133)
|
||
|
||
Maximum finite value[.](#members-5.sentence-1)[162](#footnote-162 "Equivalent to CHAR_MAX, SHRT_MAX, FLT_MAX, DBL_MAX, etc.")
|
||
|
||
[6](#members-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1140)
|
||
|
||
Meaningful for all specializations in whichis_bounded != false[.](#members-6.sentence-1)
|
||
|
||
[ð](#lib:lowest,numeric_limits)
|
||
|
||
`static constexpr T lowest() noexcept;
|
||
`
|
||
|
||
[7](#members-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1151)
|
||
|
||
A finite value x such that there is no other finite
|
||
value y where y < x[.](#members-7.sentence-1)[163](#footnote-163 "lowest() is necessary because not all floating-point representations have a smallest (most negative) value that is the negative of the largest (most positive) finite value.")
|
||
|
||
[8](#members-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1160)
|
||
|
||
Meaningful for all specializations in which is_bounded != false[.](#members-8.sentence-1)
|
||
|
||
[ð](#lib:digits,numeric_limits)
|
||
|
||
`static constexpr int digits;
|
||
`
|
||
|
||
[9](#members-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1170)
|
||
|
||
Number ofradix digits that can be represented without change[.](#members-9.sentence-1)
|
||
|
||
[10](#members-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1175)
|
||
|
||
For integer types, the number of non-sign bits in the representation[.](#members-10.sentence-1)
|
||
|
||
[11](#members-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1178)
|
||
|
||
For floating-point types, the number of radix digits in the
|
||
significand[.](#members-11.sentence-1)[164](#footnote-164 "Equivalent to FLT_MANT_DIG, DBL_MANT_DIG, LDBL_MANT_DIG.")
|
||
|
||
[ð](#lib:digits10,numeric_limits)
|
||
|
||
`static constexpr int digits10;
|
||
`
|
||
|
||
[12](#members-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1193)
|
||
|
||
Number of base 10 digits that can be represented without
|
||
change[.](#members-12.sentence-1)[165](#footnote-165 "Equivalent to FLT_DIG, DBL_DIG, LDBL_DIG.")
|
||
|
||
[13](#members-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1201)
|
||
|
||
Meaningful for all specializations in whichis_bounded != false[.](#members-13.sentence-1)
|
||
|
||
[ð](#lib:max_digits10,numeric_limits)
|
||
|
||
`static constexpr int max_digits10;
|
||
`
|
||
|
||
[14](#members-14)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1212)
|
||
|
||
Number of base 10 digits required to ensure that values which
|
||
differ are always differentiated[.](#members-14.sentence-1)
|
||
|
||
[15](#members-15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1216)
|
||
|
||
Meaningful for all floating-point types[.](#members-15.sentence-1)
|
||
|
||
[ð](#lib:is_signed,numeric_limits)
|
||
|
||
`static constexpr bool is_signed;
|
||
`
|
||
|
||
[16](#members-16)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1226)
|
||
|
||
true if the type is signed[.](#members-16.sentence-1)
|
||
|
||
[17](#members-17)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1229)
|
||
|
||
Meaningful for all specializations[.](#members-17.sentence-1)
|
||
|
||
[ð](#lib:is_integer,numeric_limits)
|
||
|
||
`static constexpr bool is_integer;
|
||
`
|
||
|
||
[18](#members-18)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1239)
|
||
|
||
true if the type is integer[.](#members-18.sentence-1)
|
||
|
||
[19](#members-19)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1242)
|
||
|
||
Meaningful for all specializations[.](#members-19.sentence-1)
|
||
|
||
[ð](#lib:is_exact,numeric_limits)
|
||
|
||
`static constexpr bool is_exact;
|
||
`
|
||
|
||
[20](#members-20)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1252)
|
||
|
||
true if the type uses an exact representation[.](#members-20.sentence-1)
|
||
|
||
All integer types are exact, but not all exact types are integer[.](#members-20.sentence-2)
|
||
|
||
For example, rational and fixed-exponent representations are exact but not integer[.](#members-20.sentence-3)
|
||
|
||
[21](#members-21)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1257)
|
||
|
||
Meaningful for all specializations[.](#members-21.sentence-1)
|
||
|
||
[ð](#lib:radix,numeric_limits)
|
||
|
||
`static constexpr int radix;
|
||
`
|
||
|
||
[22](#members-22)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1267)
|
||
|
||
For floating-point types, specifies the base or radix of the exponent representation
|
||
(often 2)[.](#members-22.sentence-1)[166](#footnote-166 "Equivalent to FLT_RADIX.")
|
||
|
||
[23](#members-23)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1274)
|
||
|
||
For integer types, specifies the base of the
|
||
representation[.](#members-23.sentence-1)[167](#footnote-167 "Distinguishes types with bases other than 2 (e.g., BCD).")
|
||
|
||
[24](#members-24)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1281)
|
||
|
||
Meaningful for all specializations[.](#members-24.sentence-1)
|
||
|
||
[ð](#lib:epsilon,numeric_limits)
|
||
|
||
`static constexpr T epsilon() noexcept;
|
||
`
|
||
|
||
[25](#members-25)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1291)
|
||
|
||
Machine epsilon: the difference between 1 and the least value greater than 1
|
||
that is representable[.](#members-25.sentence-1)[168](#footnote-168 "Equivalent to FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON.")
|
||
|
||
[26](#members-26)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1298)
|
||
|
||
Meaningful for all floating-point types[.](#members-26.sentence-1)
|
||
|
||
[ð](#lib:round_error,numeric_limits)
|
||
|
||
`static constexpr T round_error() noexcept;
|
||
`
|
||
|
||
[27](#members-27)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1308)
|
||
|
||
Measure of the maximum rounding error[.](#members-27.sentence-1)[169](#footnote-169 "Rounding error is described in ISO/IEC 10967-1:2012 Section 5.2.4 and Annex C Rationale Section C.5.2.4 â Rounding and rounding constants.")
|
||
|
||
[ð](#lib:min_exponent,numeric_limits)
|
||
|
||
`static constexpr int min_exponent;
|
||
`
|
||
|
||
[28](#members-28)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1322)
|
||
|
||
Minimum negative integer such thatradix raised to the power of one less than that integer is a normalized floating-point
|
||
number[.](#members-28.sentence-1)[170](#footnote-170 "Equivalent to FLT_MIN_EXP, DBL_MIN_EXP, LDBL_MIN_EXP.")
|
||
|
||
[29](#members-29)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1332)
|
||
|
||
Meaningful for all floating-point types[.](#members-29.sentence-1)
|
||
|
||
[ð](#lib:min_exponent10,numeric_limits)
|
||
|
||
`static constexpr int min_exponent10;
|
||
`
|
||
|
||
[30](#members-30)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1342)
|
||
|
||
Minimum negative integer such that 10 raised to that power is in the range
|
||
of normalized floating-point numbers[.](#members-30.sentence-1)[171](#footnote-171 "Equivalent to FLT_MIN_10_EXP, DBL_MIN_10_EXP, LDBL_MIN_10_EXP.")
|
||
|
||
[31](#members-31)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1350)
|
||
|
||
Meaningful for all floating-point types[.](#members-31.sentence-1)
|
||
|
||
[ð](#lib:max_exponent,numeric_limits)
|
||
|
||
`static constexpr int max_exponent;
|
||
`
|
||
|
||
[32](#members-32)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1360)
|
||
|
||
Maximum positive integer such thatradix raised to the power one less than that integer is a representable finite
|
||
floating-point number[.](#members-32.sentence-1)[172](#footnote-172 "Equivalent to FLT_MAX_EXP, DBL_MAX_EXP, LDBL_MAX_EXP.")
|
||
|
||
[33](#members-33)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1370)
|
||
|
||
Meaningful for all floating-point types[.](#members-33.sentence-1)
|
||
|
||
[ð](#lib:max_exponent10,numeric_limits)
|
||
|
||
`static constexpr int max_exponent10;
|
||
`
|
||
|
||
[34](#members-34)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1380)
|
||
|
||
Maximum positive integer such that 10 raised to that power is in the
|
||
range of representable finite floating-point numbers[.](#members-34.sentence-1)[173](#footnote-173 "Equivalent to FLT_MAX_10_EXP, DBL_MAX_10_EXP, LDBL_MAX_10_EXP.")
|
||
|
||
[35](#members-35)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1388)
|
||
|
||
Meaningful for all floating-point types[.](#members-35.sentence-1)
|
||
|
||
[ð](#lib:has_infinity,numeric_limits)
|
||
|
||
`static constexpr bool has_infinity;
|
||
`
|
||
|
||
[36](#members-36)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1398)
|
||
|
||
true if the type has a representation for positive infinity[.](#members-36.sentence-1)
|
||
|
||
[37](#members-37)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1401)
|
||
|
||
Meaningful for all floating-point types[.](#members-37.sentence-1)
|
||
|
||
[38](#members-38)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1404)
|
||
|
||
Shall betrue for all specializations in whichis_iec559 != false[.](#members-38.sentence-1)
|
||
|
||
[ð](#lib:has_quiet_NaN,numeric_limits)
|
||
|
||
`static constexpr bool has_quiet_NaN;
|
||
`
|
||
|
||
[39](#members-39)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1417)
|
||
|
||
true if the type has a representation for a quiet (non-signaling) âNot a
|
||
Numberâ[.](#members-39.sentence-1)[174](#footnote-174 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[40](#members-40)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1424)
|
||
|
||
Meaningful for all floating-point types[.](#members-40.sentence-1)
|
||
|
||
[41](#members-41)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1427)
|
||
|
||
Shall betrue for all specializations in whichis_iec559 != false[.](#members-41.sentence-1)
|
||
|
||
[ð](#lib:has_signaling_NaN,numeric_limits)
|
||
|
||
`static constexpr bool has_signaling_NaN;
|
||
`
|
||
|
||
[42](#members-42)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1440)
|
||
|
||
true if the type has a representation for a signaling âNot a Numberâ[.](#members-42.sentence-1)[175](#footnote-175 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[43](#members-43)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1446)
|
||
|
||
Meaningful for all floating-point types[.](#members-43.sentence-1)
|
||
|
||
[44](#members-44)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1449)
|
||
|
||
Shall betrue for all specializations in whichis_iec559 != false[.](#members-44.sentence-1)
|
||
|
||
[ð](#lib:infinity,numeric_limits)
|
||
|
||
`static constexpr T infinity() noexcept;
|
||
`
|
||
|
||
[45](#members-45)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1462)
|
||
|
||
Representation of positive infinity, if available[.](#members-45.sentence-1)[176](#footnote-176 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[46](#members-46)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1468)
|
||
|
||
Meaningful for all specializations for whichhas_infinity != false[.](#members-46.sentence-1)
|
||
|
||
Required in specializations for whichis_iec559 != false[.](#members-46.sentence-2)
|
||
|
||
[ð](#lib:quiet_NaN,numeric_limits)
|
||
|
||
`static constexpr T quiet_NaN() noexcept;
|
||
`
|
||
|
||
[47](#members-47)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1481)
|
||
|
||
Representation of a quiet âNot a Numberâ, if available[.](#members-47.sentence-1)[177](#footnote-177 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[48](#members-48)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1487)
|
||
|
||
Meaningful for all specializations for whichhas_quiet_NaN != false[.](#members-48.sentence-1)
|
||
|
||
Required in specializations for whichis_iec559 != false[.](#members-48.sentence-2)
|
||
|
||
[ð](#lib:signaling_NaN,numeric_limits)
|
||
|
||
`static constexpr T signaling_NaN() noexcept;
|
||
`
|
||
|
||
[49](#members-49)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1500)
|
||
|
||
Representation of a signaling âNot a Numberâ, if available[.](#members-49.sentence-1)[178](#footnote-178 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[50](#members-50)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1506)
|
||
|
||
Meaningful for all specializations for whichhas_signaling_NaN != false[.](#members-50.sentence-1)
|
||
|
||
Required in specializations for whichis_iec559 != false[.](#members-50.sentence-2)
|
||
|
||
[ð](#lib:denorm_min,numeric_limits)
|
||
|
||
`static constexpr T denorm_min() noexcept;
|
||
`
|
||
|
||
[51](#members-51)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1520)
|
||
|
||
Minimum positive subnormal value, if available[.](#members-51.sentence-1)[179](#footnote-179 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
Otherwise, minimum positive normalized value[.](#members-51.sentence-2)
|
||
|
||
[52](#members-52)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1527)
|
||
|
||
Meaningful for all floating-point types[.](#members-52.sentence-1)
|
||
|
||
[ð](#lib:is_iec559,numeric_limits)
|
||
|
||
`static constexpr bool is_iec559;
|
||
`
|
||
|
||
[53](#members-53)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1537)
|
||
|
||
true if and only if the type adheres to ISO/IEC 60559[.](#members-53.sentence-1)[180](#footnote-180 "ISO/IEC 60559:2020 is the same as IEEE 754-2019.")
|
||
|
||
[*Note [2](#members-note-2)*:
|
||
|
||
The value is true for any of the typesfloat16_t, float32_t, float64_t, or float128_t,
|
||
if present ([[basic.extended.fp]](basic.extended.fp "6.9.3 Optional extended floating-point types"))[.](#members-53.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[54](#members-54)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1548)
|
||
|
||
Meaningful for all floating-point types[.](#members-54.sentence-1)
|
||
|
||
[ð](#lib:is_bounded,numeric_limits)
|
||
|
||
`static constexpr bool is_bounded;
|
||
`
|
||
|
||
[55](#members-55)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1558)
|
||
|
||
true if the set of values representable by the type is finite[.](#members-55.sentence-1)[181](#footnote-181 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[*Note [3](#members-note-3)*:
|
||
|
||
All fundamental types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types")) are bounded[.](#members-55.sentence-2)
|
||
|
||
This member would be false for arbitrary
|
||
precision types[.](#members-55.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
[56](#members-56)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1568)
|
||
|
||
Meaningful for all specializations[.](#members-56.sentence-1)
|
||
|
||
[ð](#lib:is_modulo,numeric_limits)
|
||
|
||
`static constexpr bool is_modulo;
|
||
`
|
||
|
||
[57](#members-57)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1578)
|
||
|
||
true if the type is modulo[.](#members-57.sentence-1)[182](#footnote-182 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
A type is modulo if, for any operation involving +, -, or* on values of that type whose result would fall outside the range
|
||
[min(), max()], the value returned differs from the true value by an
|
||
integer multiple of max() - min() + 1[.](#members-57.sentence-2)
|
||
|
||
[58](#members-58)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1588)
|
||
|
||
[*Example [1](#members-example-1)*:
|
||
|
||
is_modulo is false for signed integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))
|
||
unless an implementation, as an extension to this document,
|
||
defines signed integer overflow to wrap[.](#members-58.sentence-1)
|
||
|
||
â *end example*]
|
||
|
||
[59](#members-59)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1595)
|
||
|
||
Meaningful for all specializations[.](#members-59.sentence-1)
|
||
|
||
[ð](#lib:traps,numeric_limits)
|
||
|
||
`static constexpr bool traps;
|
||
`
|
||
|
||
[60](#members-60)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1605)
|
||
|
||
true if, at the start of the program, there exists a value of the type that would cause
|
||
an arithmetic operation using that value to trap[.](#members-60.sentence-1)[183](#footnote-183 "Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[61](#members-61)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1613)
|
||
|
||
Meaningful for all specializations[.](#members-61.sentence-1)
|
||
|
||
[ð](#lib:tinyness_before,numeric_limits)
|
||
|
||
`static constexpr bool tinyness_before;
|
||
`
|
||
|
||
[62](#members-62)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1623)
|
||
|
||
true if tinyness is detected before rounding[.](#members-62.sentence-1)[184](#footnote-184 "Refer to ISO/IEC 60559. Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[63](#members-63)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1632)
|
||
|
||
Meaningful for all floating-point types[.](#members-63.sentence-1)
|
||
|
||
[ð](#lib:round_style,numeric_limits)
|
||
|
||
`static constexpr float_round_style round_style;
|
||
`
|
||
|
||
[64](#members-64)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1642)
|
||
|
||
The rounding style for the type[.](#members-64.sentence-1)[185](#footnote-185 "Equivalent to FLT_ROUNDS. Required by ISO/IEC 10967-1:2012.")
|
||
|
||
[65](#members-65)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1649)
|
||
|
||
Meaningful for all floating-point types[.](#members-65.sentence-1)
|
||
|
||
Specializations for integer types shall returnround_toward_zero[.](#members-65.sentence-2)
|
||
|
||
[161)](#footnote-161)[161)](#footnoteref-161)
|
||
|
||
Equivalent to CHAR_MIN, SHRT_MIN,FLT_MIN, DBL_MIN, etc[.](#footnote-161.sentence-1)
|
||
|
||
[162)](#footnote-162)[162)](#footnoteref-162)
|
||
|
||
Equivalent to CHAR_MAX, SHRT_MAX,FLT_MAX, DBL_MAX, etc[.](#footnote-162.sentence-1)
|
||
|
||
[163)](#footnote-163)[163)](#footnoteref-163)
|
||
|
||
lowest() is necessary because not all
|
||
floating-point representations have a smallest (most negative) value that is
|
||
the negative of the largest (most positive) finite value[.](#footnote-163.sentence-1)
|
||
|
||
[164)](#footnote-164)[164)](#footnoteref-164)
|
||
|
||
Equivalent to FLT_MANT_DIG, DBL_MANT_DIG,LDBL_MANT_DIG[.](#footnote-164.sentence-1)
|
||
|
||
[165)](#footnote-165)[165)](#footnoteref-165)
|
||
|
||
Equivalent to FLT_DIG, DBL_DIG,LDBL_DIG[.](#footnote-165.sentence-1)
|
||
|
||
[166)](#footnote-166)[166)](#footnoteref-166)
|
||
|
||
Equivalent to FLT_RADIX[.](#footnote-166.sentence-1)
|
||
|
||
[167)](#footnote-167)[167)](#footnoteref-167)
|
||
|
||
Distinguishes types with bases other than 2 (e.g., BCD)[.](#footnote-167.sentence-1)
|
||
|
||
[168)](#footnote-168)[168)](#footnoteref-168)
|
||
|
||
Equivalent to FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON[.](#footnote-168.sentence-1)
|
||
|
||
[169)](#footnote-169)[169)](#footnoteref-169)
|
||
|
||
Rounding error is described in ISO/IEC 10967-1:2012 Section 5.2.4 and
|
||
Annex C Rationale Section C.5.2.4 â Rounding and rounding constants[.](#footnote-169.sentence-1)
|
||
|
||
[170)](#footnote-170)[170)](#footnoteref-170)
|
||
|
||
Equivalent to FLT_MIN_EXP, DBL_MIN_EXP,LDBL_MIN_EXP[.](#footnote-170.sentence-1)
|
||
|
||
[171)](#footnote-171)[171)](#footnoteref-171)
|
||
|
||
Equivalent toFLT_MIN_10_EXP, DBL_MIN_10_EXP, LDBL_MIN_10_EXP[.](#footnote-171.sentence-1)
|
||
|
||
[172)](#footnote-172)[172)](#footnoteref-172)
|
||
|
||
Equivalent to FLT_MAX_EXP,DBL_MAX_EXP, LDBL_MAX_EXP[.](#footnote-172.sentence-1)
|
||
|
||
[173)](#footnote-173)[173)](#footnoteref-173)
|
||
|
||
Equivalent toFLT_MAX_10_EXP, DBL_MAX_10_EXP, LDBL_MAX_10_EXP[.](#footnote-173.sentence-1)
|
||
|
||
[174)](#footnote-174)[174)](#footnoteref-174)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-174.sentence-1)
|
||
|
||
[175)](#footnote-175)[175)](#footnoteref-175)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-175.sentence-1)
|
||
|
||
[176)](#footnote-176)[176)](#footnoteref-176)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-176.sentence-1)
|
||
|
||
[177)](#footnote-177)[177)](#footnoteref-177)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-177.sentence-1)
|
||
|
||
[178)](#footnote-178)[178)](#footnoteref-178)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-178.sentence-1)
|
||
|
||
[179)](#footnote-179)[179)](#footnoteref-179)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-179.sentence-1)
|
||
|
||
[180)](#footnote-180)[180)](#footnoteref-180)
|
||
|
||
ISO/IEC 60559:2020 is the same as IEEE 754-2019[.](#footnote-180.sentence-1)
|
||
|
||
[181)](#footnote-181)[181)](#footnoteref-181)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-181.sentence-1)
|
||
|
||
[182)](#footnote-182)[182)](#footnoteref-182)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-182.sentence-1)
|
||
|
||
[183)](#footnote-183)[183)](#footnoteref-183)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-183.sentence-1)
|
||
|
||
[184)](#footnote-184)[184)](#footnoteref-184)
|
||
|
||
Refer to
|
||
ISO/IEC 60559[.](#footnote-184.sentence-1)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-184.sentence-2)
|
||
|
||
[185)](#footnote-185)[185)](#footnoteref-185)
|
||
|
||
Equivalent to FLT_ROUNDS[.](#footnote-185.sentence-1)
|
||
|
||
Required by ISO/IEC 10967-1:2012[.](#footnote-185.sentence-2)
|
||
|
||
#### [17.3.5.3](#numeric.special) numeric_limits specializations [[numeric.special]](numeric.special)
|
||
|
||
[1](#numeric.special-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1657)
|
||
|
||
All members shall be provided for all specializations[.](#numeric.special-1.sentence-1)
|
||
|
||
However, many values are only required to be meaningful under certain
|
||
conditions
|
||
(for example,epsilon() is only meaningful ifis_integer isfalse)[.](#numeric.special-1.sentence-2)
|
||
|
||
Any value that is not âmeaningfulâ shall be set to 0 orfalse[.](#numeric.special-1.sentence-3)
|
||
|
||
[2](#numeric.special-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1670)
|
||
|
||
[*Example [1](#numeric.special-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](#numeric.special-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; };}
|