Init
This commit is contained in:
50
cppdraft/numeric/iota.md
Normal file
50
cppdraft/numeric/iota.md
Normal file
@@ -0,0 +1,50 @@
|
||||
[numeric.iota]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#numeric.iota)
|
||||
|
||||
### 26.10.13 Iota [numeric.iota]
|
||||
|
||||
[ð](#lib:iota)
|
||||
|
||||
`template<class ForwardIterator, class T>
|
||||
constexpr void iota(ForwardIterator first, ForwardIterator last, T value);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13224)
|
||||
|
||||
*Mandates*: T is convertible to ForwardIterator's value type[.](#1.sentence-1)
|
||||
|
||||
The expression ++val, where val has type T,
|
||||
is well-formed[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13230)
|
||||
|
||||
*Effects*: For each element referred to by the iterator i in the range [first, last),
|
||||
assigns *i = value and increments value as if by ++value[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13237)
|
||||
|
||||
*Complexity*: Exactly last - first increments and assignments[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:iota_)
|
||||
|
||||
`template<[input_or_output_iterator](iterator.concept.iterator#concept:input_or_output_iterator "24.3.4.6 Concept input_or_output_iterator [iterator.concept.iterator]") O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<O> S, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") T>
|
||||
requires [indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_writable [iterator.concept.writable]")<O, const T&>
|
||||
constexpr ranges::iota_result<O, T> ranges::iota(O first, S last, T value);
|
||||
template<[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") T, [output_range](range.refinements#concept:output_range "25.4.6 Other range refinements [range.refinements]")<const T&> R>
|
||||
constexpr ranges::iota_result<borrowed_iterator_t<R>, T> ranges::iota(R&& r, T value);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13252)
|
||||
|
||||
*Effects*: Equivalent to:while (first != last) {*first = as_const(value); ++first; ++value;}return {std::move(first), std::move(value)};
|
||||
803
cppdraft/numeric/limits.md
Normal file
803
cppdraft/numeric/limits.md
Normal file
@@ -0,0 +1,803 @@
|
||||
[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; };}
|
||||
66
cppdraft/numeric/limits/general.md
Normal file
66
cppdraft/numeric/limits/general.md
Normal file
@@ -0,0 +1,66 @@
|
||||
[numeric.limits.general]
|
||||
|
||||
# 17 Language support library [[support]](./#support)
|
||||
|
||||
## 17.3 Implementation properties [[support.limits]](support.limits#numeric.limits.general)
|
||||
|
||||
### 17.3.5 Class template numeric_limits [[numeric.limits]](numeric.limits#general)
|
||||
|
||||
#### 17.3.5.1 General [numeric.limits.general]
|
||||
|
||||
[1](#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[.](#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](#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[.](#2.sentence-1)
|
||||
|
||||
[3](#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[.](#3.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
This means all members have zero or false values
|
||||
unless numeric_limits is specialized for a type[.](#3.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[4](#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[.](#4.sentence-1)
|
||||
|
||||
The memberis_specialized shall betrue for all such specializations ofnumeric_limits[.](#4.sentence-2)
|
||||
|
||||
[5](#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[.](#5.sentence-1)
|
||||
|
||||
[6](#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[.](#6.sentence-1)
|
||||
714
cppdraft/numeric/limits/members.md
Normal file
714
cppdraft/numeric/limits/members.md
Normal file
@@ -0,0 +1,714 @@
|
||||
[numeric.limits.members]
|
||||
|
||||
# 17 Language support library [[support]](./#support)
|
||||
|
||||
## 17.3 Implementation properties [[support.limits]](support.limits#numeric.limits.members)
|
||||
|
||||
### 17.3.5 Class template numeric_limits [[numeric.limits]](numeric.limits#members)
|
||||
|
||||
#### 17.3.5.2 numeric_limits members [numeric.limits.members]
|
||||
|
||||
[1](#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"))[.](#1.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The arithmetic specification described in ISO/IEC 10967-1:2012 is
|
||||
commonly termed LIA-1[.](#1.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[ð](#lib:min,numeric_limits)
|
||||
|
||||
`static constexpr T min() noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1108)
|
||||
|
||||
Minimum finite value[.](#2.sentence-1)[161](#footnote-161 "Equivalent to CHAR_MIN, SHRT_MIN, FLT_MIN, DBL_MIN, etc.")
|
||||
|
||||
[3](#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[.](#3.sentence-1)
|
||||
|
||||
[4](#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[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:max,numeric_limits)
|
||||
|
||||
`static constexpr T max() noexcept;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1133)
|
||||
|
||||
Maximum finite value[.](#5.sentence-1)[162](#footnote-162 "Equivalent to CHAR_MAX, SHRT_MAX, FLT_MAX, DBL_MAX, etc.")
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1140)
|
||||
|
||||
Meaningful for all specializations in whichis_bounded != false[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:lowest,numeric_limits)
|
||||
|
||||
`static constexpr T lowest() noexcept;
|
||||
`
|
||||
|
||||
[7](#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[.](#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](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1160)
|
||||
|
||||
Meaningful for all specializations in which is_bounded != false[.](#8.sentence-1)
|
||||
|
||||
[ð](#lib:digits,numeric_limits)
|
||||
|
||||
`static constexpr int digits;
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1170)
|
||||
|
||||
Number ofradix digits that can be represented without change[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1175)
|
||||
|
||||
For integer types, the number of non-sign bits in the representation[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1178)
|
||||
|
||||
For floating-point types, the number of radix digits in the
|
||||
significand[.](#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](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1193)
|
||||
|
||||
Number of base 10 digits that can be represented without
|
||||
change[.](#12.sentence-1)[165](#footnote-165 "Equivalent to FLT_DIG, DBL_DIG, LDBL_DIG.")
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1201)
|
||||
|
||||
Meaningful for all specializations in whichis_bounded != false[.](#13.sentence-1)
|
||||
|
||||
[ð](#lib:max_digits10,numeric_limits)
|
||||
|
||||
`static constexpr int max_digits10;
|
||||
`
|
||||
|
||||
[14](#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[.](#14.sentence-1)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1216)
|
||||
|
||||
Meaningful for all floating-point types[.](#15.sentence-1)
|
||||
|
||||
[ð](#lib:is_signed,numeric_limits)
|
||||
|
||||
`static constexpr bool is_signed;
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1226)
|
||||
|
||||
true if the type is signed[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1229)
|
||||
|
||||
Meaningful for all specializations[.](#17.sentence-1)
|
||||
|
||||
[ð](#lib:is_integer,numeric_limits)
|
||||
|
||||
`static constexpr bool is_integer;
|
||||
`
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1239)
|
||||
|
||||
true if the type is integer[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1242)
|
||||
|
||||
Meaningful for all specializations[.](#19.sentence-1)
|
||||
|
||||
[ð](#lib:is_exact,numeric_limits)
|
||||
|
||||
`static constexpr bool is_exact;
|
||||
`
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1252)
|
||||
|
||||
true if the type uses an exact representation[.](#20.sentence-1)
|
||||
|
||||
All integer types are exact, but not all exact types are integer[.](#20.sentence-2)
|
||||
|
||||
For example, rational and fixed-exponent representations are exact but not integer[.](#20.sentence-3)
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1257)
|
||||
|
||||
Meaningful for all specializations[.](#21.sentence-1)
|
||||
|
||||
[ð](#lib:radix,numeric_limits)
|
||||
|
||||
`static constexpr int radix;
|
||||
`
|
||||
|
||||
[22](#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)[.](#22.sentence-1)[166](#footnote-166 "Equivalent to FLT_RADIX.")
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1274)
|
||||
|
||||
For integer types, specifies the base of the
|
||||
representation[.](#23.sentence-1)[167](#footnote-167 "Distinguishes types with bases other than 2 (e.g., BCD).")
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1281)
|
||||
|
||||
Meaningful for all specializations[.](#24.sentence-1)
|
||||
|
||||
[ð](#lib:epsilon,numeric_limits)
|
||||
|
||||
`static constexpr T epsilon() noexcept;
|
||||
`
|
||||
|
||||
[25](#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[.](#25.sentence-1)[168](#footnote-168 "Equivalent to FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON.")
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1298)
|
||||
|
||||
Meaningful for all floating-point types[.](#26.sentence-1)
|
||||
|
||||
[ð](#lib:round_error,numeric_limits)
|
||||
|
||||
`static constexpr T round_error() noexcept;
|
||||
`
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1308)
|
||||
|
||||
Measure of the maximum rounding error[.](#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](#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[.](#28.sentence-1)[170](#footnote-170 "Equivalent to FLT_MIN_EXP, DBL_MIN_EXP, LDBL_MIN_EXP.")
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1332)
|
||||
|
||||
Meaningful for all floating-point types[.](#29.sentence-1)
|
||||
|
||||
[ð](#lib:min_exponent10,numeric_limits)
|
||||
|
||||
`static constexpr int min_exponent10;
|
||||
`
|
||||
|
||||
[30](#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[.](#30.sentence-1)[171](#footnote-171 "Equivalent to FLT_MIN_10_EXP, DBL_MIN_10_EXP, LDBL_MIN_10_EXP.")
|
||||
|
||||
[31](#31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1350)
|
||||
|
||||
Meaningful for all floating-point types[.](#31.sentence-1)
|
||||
|
||||
[ð](#lib:max_exponent,numeric_limits)
|
||||
|
||||
`static constexpr int max_exponent;
|
||||
`
|
||||
|
||||
[32](#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[.](#32.sentence-1)[172](#footnote-172 "Equivalent to FLT_MAX_EXP, DBL_MAX_EXP, LDBL_MAX_EXP.")
|
||||
|
||||
[33](#33)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1370)
|
||||
|
||||
Meaningful for all floating-point types[.](#33.sentence-1)
|
||||
|
||||
[ð](#lib:max_exponent10,numeric_limits)
|
||||
|
||||
`static constexpr int max_exponent10;
|
||||
`
|
||||
|
||||
[34](#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[.](#34.sentence-1)[173](#footnote-173 "Equivalent to FLT_MAX_10_EXP, DBL_MAX_10_EXP, LDBL_MAX_10_EXP.")
|
||||
|
||||
[35](#35)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1388)
|
||||
|
||||
Meaningful for all floating-point types[.](#35.sentence-1)
|
||||
|
||||
[ð](#lib:has_infinity,numeric_limits)
|
||||
|
||||
`static constexpr bool has_infinity;
|
||||
`
|
||||
|
||||
[36](#36)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1398)
|
||||
|
||||
true if the type has a representation for positive infinity[.](#36.sentence-1)
|
||||
|
||||
[37](#37)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1401)
|
||||
|
||||
Meaningful for all floating-point types[.](#37.sentence-1)
|
||||
|
||||
[38](#38)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1404)
|
||||
|
||||
Shall betrue for all specializations in whichis_iec559 != false[.](#38.sentence-1)
|
||||
|
||||
[ð](#lib:has_quiet_NaN,numeric_limits)
|
||||
|
||||
`static constexpr bool has_quiet_NaN;
|
||||
`
|
||||
|
||||
[39](#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â[.](#39.sentence-1)[174](#footnote-174 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[40](#40)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1424)
|
||||
|
||||
Meaningful for all floating-point types[.](#40.sentence-1)
|
||||
|
||||
[41](#41)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1427)
|
||||
|
||||
Shall betrue for all specializations in whichis_iec559 != false[.](#41.sentence-1)
|
||||
|
||||
[ð](#lib:has_signaling_NaN,numeric_limits)
|
||||
|
||||
`static constexpr bool has_signaling_NaN;
|
||||
`
|
||||
|
||||
[42](#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â[.](#42.sentence-1)[175](#footnote-175 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[43](#43)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1446)
|
||||
|
||||
Meaningful for all floating-point types[.](#43.sentence-1)
|
||||
|
||||
[44](#44)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1449)
|
||||
|
||||
Shall betrue for all specializations in whichis_iec559 != false[.](#44.sentence-1)
|
||||
|
||||
[ð](#lib:infinity,numeric_limits)
|
||||
|
||||
`static constexpr T infinity() noexcept;
|
||||
`
|
||||
|
||||
[45](#45)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1462)
|
||||
|
||||
Representation of positive infinity, if available[.](#45.sentence-1)[176](#footnote-176 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[46](#46)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1468)
|
||||
|
||||
Meaningful for all specializations for whichhas_infinity != false[.](#46.sentence-1)
|
||||
|
||||
Required in specializations for whichis_iec559 != false[.](#46.sentence-2)
|
||||
|
||||
[ð](#lib:quiet_NaN,numeric_limits)
|
||||
|
||||
`static constexpr T quiet_NaN() noexcept;
|
||||
`
|
||||
|
||||
[47](#47)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1481)
|
||||
|
||||
Representation of a quiet âNot a Numberâ, if available[.](#47.sentence-1)[177](#footnote-177 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[48](#48)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1487)
|
||||
|
||||
Meaningful for all specializations for whichhas_quiet_NaN != false[.](#48.sentence-1)
|
||||
|
||||
Required in specializations for whichis_iec559 != false[.](#48.sentence-2)
|
||||
|
||||
[ð](#lib:signaling_NaN,numeric_limits)
|
||||
|
||||
`static constexpr T signaling_NaN() noexcept;
|
||||
`
|
||||
|
||||
[49](#49)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1500)
|
||||
|
||||
Representation of a signaling âNot a Numberâ, if available[.](#49.sentence-1)[178](#footnote-178 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[50](#50)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1506)
|
||||
|
||||
Meaningful for all specializations for whichhas_signaling_NaN != false[.](#50.sentence-1)
|
||||
|
||||
Required in specializations for whichis_iec559 != false[.](#50.sentence-2)
|
||||
|
||||
[ð](#lib:denorm_min,numeric_limits)
|
||||
|
||||
`static constexpr T denorm_min() noexcept;
|
||||
`
|
||||
|
||||
[51](#51)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1520)
|
||||
|
||||
Minimum positive subnormal value, if available[.](#51.sentence-1)[179](#footnote-179 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
Otherwise, minimum positive normalized value[.](#51.sentence-2)
|
||||
|
||||
[52](#52)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1527)
|
||||
|
||||
Meaningful for all floating-point types[.](#52.sentence-1)
|
||||
|
||||
[ð](#lib:is_iec559,numeric_limits)
|
||||
|
||||
`static constexpr bool is_iec559;
|
||||
`
|
||||
|
||||
[53](#53)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1537)
|
||||
|
||||
true if and only if the type adheres to ISO/IEC 60559[.](#53.sentence-1)[180](#footnote-180 "ISO/IEC 60559:2020 is the same as IEEE 754-2019.")
|
||||
|
||||
[*Note [2](#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"))[.](#53.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[54](#54)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1548)
|
||||
|
||||
Meaningful for all floating-point types[.](#54.sentence-1)
|
||||
|
||||
[ð](#lib:is_bounded,numeric_limits)
|
||||
|
||||
`static constexpr bool is_bounded;
|
||||
`
|
||||
|
||||
[55](#55)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1558)
|
||||
|
||||
true if the set of values representable by the type is finite[.](#55.sentence-1)[181](#footnote-181 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[*Note [3](#note-3)*:
|
||||
|
||||
All fundamental types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types")) are bounded[.](#55.sentence-2)
|
||||
|
||||
This member would be false for arbitrary
|
||||
precision types[.](#55.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[56](#56)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1568)
|
||||
|
||||
Meaningful for all specializations[.](#56.sentence-1)
|
||||
|
||||
[ð](#lib:is_modulo,numeric_limits)
|
||||
|
||||
`static constexpr bool is_modulo;
|
||||
`
|
||||
|
||||
[57](#57)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1578)
|
||||
|
||||
true if the type is modulo[.](#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[.](#57.sentence-2)
|
||||
|
||||
[58](#58)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1588)
|
||||
|
||||
[*Example [1](#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[.](#58.sentence-1)
|
||||
|
||||
â *end example*]
|
||||
|
||||
[59](#59)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1595)
|
||||
|
||||
Meaningful for all specializations[.](#59.sentence-1)
|
||||
|
||||
[ð](#lib:traps,numeric_limits)
|
||||
|
||||
`static constexpr bool traps;
|
||||
`
|
||||
|
||||
[60](#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[.](#60.sentence-1)[183](#footnote-183 "Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[61](#61)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1613)
|
||||
|
||||
Meaningful for all specializations[.](#61.sentence-1)
|
||||
|
||||
[ð](#lib:tinyness_before,numeric_limits)
|
||||
|
||||
`static constexpr bool tinyness_before;
|
||||
`
|
||||
|
||||
[62](#62)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1623)
|
||||
|
||||
true if tinyness is detected before rounding[.](#62.sentence-1)[184](#footnote-184 "Refer to ISO/IEC 60559. Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[63](#63)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1632)
|
||||
|
||||
Meaningful for all floating-point types[.](#63.sentence-1)
|
||||
|
||||
[ð](#lib:round_style,numeric_limits)
|
||||
|
||||
`static constexpr float_round_style round_style;
|
||||
`
|
||||
|
||||
[64](#64)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1642)
|
||||
|
||||
The rounding style for the type[.](#64.sentence-1)[185](#footnote-185 "Equivalent to FLT_ROUNDS. Required by ISO/IEC 10967-1:2012.")
|
||||
|
||||
[65](#65)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L1649)
|
||||
|
||||
Meaningful for all floating-point types[.](#65.sentence-1)
|
||||
|
||||
Specializations for integer types shall returnround_toward_zero[.](#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)
|
||||
1449
cppdraft/numeric/ops.md
Normal file
1449
cppdraft/numeric/ops.md
Normal file
File diff suppressed because it is too large
Load Diff
47
cppdraft/numeric/ops/gcd.md
Normal file
47
cppdraft/numeric/ops/gcd.md
Normal file
@@ -0,0 +1,47 @@
|
||||
[numeric.ops.gcd]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#gcd)
|
||||
|
||||
### 26.10.14 Greatest common divisor [numeric.ops.gcd]
|
||||
|
||||
[ð](#lib:gcd)
|
||||
|
||||
`template<class M, class N>
|
||||
constexpr common_type_t<M, N> gcd(M m, N n);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13274)
|
||||
|
||||
*Mandates*: M and N both are integer types other thancv bool[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13279)
|
||||
|
||||
*Preconditions*: |m| and |n| are representable as a value of common_type_t<M, N>[.](#2.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
These requirements ensure, for example,
|
||||
that gcd(m, m)=|m| is representable as a value of type M[.](#2.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13290)
|
||||
|
||||
*Returns*: Zero when m and n are both zero[.](#3.sentence-1)
|
||||
|
||||
Otherwise,
|
||||
returns the greatest common divisor of |m| and |n|[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13295)
|
||||
|
||||
*Throws*: Nothing[.](#4.sentence-1)
|
||||
18
cppdraft/numeric/ops/general.md
Normal file
18
cppdraft/numeric/ops/general.md
Normal file
@@ -0,0 +1,18 @@
|
||||
[numeric.ops.general]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#general)
|
||||
|
||||
### 26.10.1 General [numeric.ops.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12261)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The use of closed ranges as well as semi-open ranges
|
||||
to specify requirements throughout [[numeric.ops]](numeric.ops "26.10 Generalized numeric operations") is intentional[.](#1.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
41
cppdraft/numeric/ops/lcm.md
Normal file
41
cppdraft/numeric/ops/lcm.md
Normal file
@@ -0,0 +1,41 @@
|
||||
[numeric.ops.lcm]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#lcm)
|
||||
|
||||
### 26.10.15 Least common multiple [numeric.ops.lcm]
|
||||
|
||||
[ð](#lib:lcm)
|
||||
|
||||
`template<class M, class N>
|
||||
constexpr common_type_t<M, N> lcm(M m, N n);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13309)
|
||||
|
||||
*Mandates*: M and N both are integer types other thancv bool[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13314)
|
||||
|
||||
*Preconditions*: |m| and |n| are representable as a value of common_type_t<M, N>[.](#2.sentence-1)
|
||||
|
||||
The least common multiple of |m| and |n| is representable as a value of type common_type_t<M, N>[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13321)
|
||||
|
||||
*Returns*: Zero when either m or n is zero[.](#3.sentence-1)
|
||||
|
||||
Otherwise, returns the least common multiple of |m| and |n|[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13326)
|
||||
|
||||
*Throws*: Nothing[.](#4.sentence-1)
|
||||
79
cppdraft/numeric/ops/midpoint.md
Normal file
79
cppdraft/numeric/ops/midpoint.md
Normal file
@@ -0,0 +1,79 @@
|
||||
[numeric.ops.midpoint]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#midpoint)
|
||||
|
||||
### 26.10.16 Midpoint [numeric.ops.midpoint]
|
||||
|
||||
[ð](#lib:midpoint)
|
||||
|
||||
`template<class T>
|
||||
constexpr T midpoint(T a, T b) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13339)
|
||||
|
||||
*Constraints*: T is an arithmetic type other than bool[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13343)
|
||||
|
||||
*Returns*: Half the sum of a and b[.](#2.sentence-1)
|
||||
|
||||
If T is an integer type and the sum is odd,
|
||||
the result is rounded towards a[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13349)
|
||||
|
||||
*Remarks*: No overflow occurs[.](#3.sentence-1)
|
||||
|
||||
If T is a floating-point type, at most one inexact operation occurs[.](#3.sentence-2)
|
||||
|
||||
[ð](#lib:midpoint_)
|
||||
|
||||
`template<class T>
|
||||
constexpr T* midpoint(T* a, T* b);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13361)
|
||||
|
||||
*Constraints*: T is an object type[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13365)
|
||||
|
||||
*Mandates*: T is a complete type[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13369)
|
||||
|
||||
*Preconditions*: a and b point to, respectively,
|
||||
elements i and j of the same array object x[.](#6.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
As specified in [[basic.compound]](basic.compound "6.9.4 Compound types"),
|
||||
an object that is not an array element
|
||||
is considered to belong to a single-element array for this purpose and
|
||||
a pointer past the last element of an array of n elements
|
||||
is considered to be equivalent to a pointer
|
||||
to a hypothetical array element n for this purpose[.](#6.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13382)
|
||||
|
||||
*Returns*: A pointer to array element i+jâi2 of x,
|
||||
where the result of the division is truncated towards zero[.](#7.sentence-1)
|
||||
74
cppdraft/numeric/ops/overview.md
Normal file
74
cppdraft/numeric/ops/overview.md
Normal file
@@ -0,0 +1,74 @@
|
||||
[numeric.ops.overview]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.9 Header <numeric> synopsis [numeric.ops.overview]
|
||||
|
||||
[ð](#header:%3cnumeric%3e)
|
||||
|
||||
// mostly freestandingnamespace std {// [[accumulate]](accumulate "26.10.3 Accumulate"), accumulatetemplate<class InputIterator, class T>constexpr T accumulate(InputIterator first, InputIterator last, T init); template<class InputIterator, class T, class BinaryOperation>constexpr T accumulate(InputIterator first, InputIterator last, T init,
|
||||
BinaryOperation binary_op); // [[reduce]](reduce "26.10.4 Reduce"), reducetemplate<class InputIterator>constexpr typename iterator_traits<InputIterator>::value_type
|
||||
reduce(InputIterator first, InputIterator last); template<class InputIterator, class T>constexpr T reduce(InputIterator first, InputIterator last, T init); template<class InputIterator, class T, class BinaryOperation>constexpr T reduce(InputIterator first, InputIterator last, T init,
|
||||
BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator>typename iterator_traits<ForwardIterator>::value_type
|
||||
reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last); template<class ExecutionPolicy, class ForwardIterator, class T> T reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last, T init); template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation> T reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last, T init, BinaryOperation binary_op); // [[inner.product]](inner.product "26.10.5 Inner product"), inner producttemplate<class InputIterator1, class InputIterator2, class T>constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init); template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init,
|
||||
BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // [[transform.reduce]](transform.reduce "26.10.6 Transform reduce"), transform reducetemplate<class InputIterator1, class InputIterator2, class T>constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init); template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init,
|
||||
BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>constexpr T transform_reduce(InputIterator first, InputIterator last, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T> T transform_reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation1, class BinaryOperation2> T transform_reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, T init,
|
||||
BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation, class UnaryOperation> T transform_reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); // [[partial.sum]](partial.sum "26.10.7 Partial sum"), partial sumtemplate<class InputIterator, class OutputIterator>constexpr OutputIterator
|
||||
partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result); template<class InputIterator, class OutputIterator, class BinaryOperation>constexpr OutputIterator
|
||||
partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op); // [[exclusive.scan]](exclusive.scan "26.10.8 Exclusive scan"), exclusive scantemplate<class InputIterator, class OutputIterator, class T>constexpr OutputIterator
|
||||
exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init); template<class InputIterator, class OutputIterator, class T, class BinaryOperation>constexpr OutputIterator
|
||||
exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init, BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T> ForwardIterator2
|
||||
exclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation> ForwardIterator2
|
||||
exclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, T init, BinaryOperation binary_op); // [[inclusive.scan]](inclusive.scan "26.10.9 Inclusive scan"), inclusive scantemplate<class InputIterator, class OutputIterator>constexpr OutputIterator
|
||||
inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result); template<class InputIterator, class OutputIterator, class BinaryOperation>constexpr OutputIterator
|
||||
inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op); template<class InputIterator, class OutputIterator, class BinaryOperation, class T>constexpr OutputIterator
|
||||
inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2> ForwardIterator2
|
||||
inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation> ForwardIterator2
|
||||
inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class T> ForwardIterator2
|
||||
inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, BinaryOperation binary_op, T init); // [[transform.exclusive.scan]](transform.exclusive.scan "26.10.10 Transform exclusive scan"), transform exclusive scantemplate<class InputIterator, class OutputIterator, class T, class BinaryOperation, class UnaryOperation>constexpr OutputIterator
|
||||
transform_exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation, class UnaryOperation> ForwardIterator2
|
||||
transform_exclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); // [[transform.inclusive.scan]](transform.inclusive.scan "26.10.11 Transform inclusive scan"), transform inclusive scantemplate<class InputIterator, class OutputIterator, class BinaryOperation, class UnaryOperation>constexpr OutputIterator
|
||||
transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); template<class InputIterator, class OutputIterator, class BinaryOperation, class UnaryOperation, class T>constexpr OutputIterator
|
||||
transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class UnaryOperation> ForwardIterator2
|
||||
transform_inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, BinaryOperation binary_op,
|
||||
UnaryOperation unary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class UnaryOperation, class T> ForwardIterator2
|
||||
transform_inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op, T init); // [[adjacent.difference]](adjacent.difference "26.10.12 Adjacent difference"), adjacent differencetemplate<class InputIterator, class OutputIterator>constexpr OutputIterator
|
||||
adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result); template<class InputIterator, class OutputIterator, class BinaryOperation>constexpr OutputIterator
|
||||
adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2> ForwardIterator2
|
||||
adjacent_difference(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation> ForwardIterator2
|
||||
adjacent_difference(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, BinaryOperation binary_op); // [[numeric.iota]](numeric.iota "26.10.13 Iota"), iotatemplate<class ForwardIterator, class T>constexpr void iota(ForwardIterator first, ForwardIterator last, T value); namespace ranges {template<class O, class T>using [iota_result](#lib:iota_result "26.9 Header <numeric> synopsis [numeric.ops.overview]") = out_value_result<O, T>; template<[input_or_output_iterator](iterator.concept.iterator#concept:input_or_output_iterator "24.3.4.6 Concept input_or_output_iterator [iterator.concept.iterator]") O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<O> S, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") T>requires [indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_writable [iterator.concept.writable]")<O, const T&>constexpr iota_result<O, T> iota(O first, S last, T value); template<[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") T, [output_range](range.refinements#concept:output_range "25.4.6 Other range refinements [range.refinements]")<const T&> R>constexpr iota_result<borrowed_iterator_t<R>, T> iota(R&& r, T value); }// [[numeric.ops.gcd]](numeric.ops.gcd "26.10.14 Greatest common divisor"), greatest common divisortemplate<class M, class N>constexpr common_type_t<M, N> gcd(M m, N n); // [[numeric.ops.lcm]](numeric.ops.lcm "26.10.15 Least common multiple"), least common multipletemplate<class M, class N>constexpr common_type_t<M, N> lcm(M m, N n); // [[numeric.ops.midpoint]](numeric.ops.midpoint "26.10.16 Midpoint"), midpointtemplate<class T>constexpr T midpoint(T a, T b) noexcept; template<class T>constexpr T* midpoint(T* a, T* b); // [[numeric.sat]](numeric.sat "26.10.17 Saturation arithmetic"), saturation arithmetictemplate<class T>constexpr T add_sat(T x, T y) noexcept; template<class T>constexpr T sub_sat(T x, T y) noexcept; template<class T>constexpr T mul_sat(T x, T y) noexcept; template<class T>constexpr T div_sat(T x, T y) noexcept; template<class T, class U>constexpr T saturate_cast(U x) noexcept;}
|
||||
48
cppdraft/numeric/requirements.md
Normal file
48
cppdraft/numeric/requirements.md
Normal file
@@ -0,0 +1,48 @@
|
||||
[numeric.requirements]
|
||||
|
||||
# 29 Numerics library [[numerics]](./#numerics)
|
||||
|
||||
## 29.2 Numeric type requirements [numeric.requirements]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L35)
|
||||
|
||||
Thecomplex andvalarray components are parameterized by the type of information they contain and manipulate[.](#1.sentence-1)
|
||||
|
||||
A C++ program shall instantiate these components only with a numeric type[.](#1.sentence-2)
|
||||
|
||||
A [*numeric type*](#def:type,numeric "29.2 Numeric type requirements [numeric.requirements]") is a cv-unqualified object type T that meets the[*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]"), and[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements ([[utility.arg.requirements]](utility.arg.requirements "16.4.4.2 Template argument requirements"))[.](#1.sentence-3)[239](#footnote-239 "In other words, value types. These include arithmetic types, pointers, the library class complex, and instantiations of valarray for value types.")
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L59)
|
||||
|
||||
If any operation on T throws an exception the effects are undefined[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L63)
|
||||
|
||||
In addition, many member and related functions ofvalarray<T> can be successfully instantiated
|
||||
and will exhibit well-defined behavior if and only ifT meets additional requirements specified for each such member
|
||||
or related function[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L71)
|
||||
|
||||
[*Example [1](#example-1)*:
|
||||
|
||||
It is valid to instantiatevalarray<complex>,
|
||||
butoperator>() will not be successfully instantiated forvalarray<complex> operands, sincecomplex does not have any ordering operators[.](#4.sentence-1)
|
||||
|
||||
â *end example*]
|
||||
|
||||
[239)](#footnote-239)[239)](#footnoteref-239)
|
||||
|
||||
In other words, value types[.](#footnote-239.sentence-1)
|
||||
|
||||
These include arithmetic types,
|
||||
pointers, the library classcomplex,
|
||||
and instantiations ofvalarray for value types[.](#footnote-239.sentence-2)
|
||||
132
cppdraft/numeric/sat.md
Normal file
132
cppdraft/numeric/sat.md
Normal file
@@ -0,0 +1,132 @@
|
||||
[numeric.sat]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#numeric.sat)
|
||||
|
||||
### 26.10.17 Saturation arithmetic [numeric.sat]
|
||||
|
||||
#### [26.10.17.1](#func) Arithmetic functions [[numeric.sat.func]](numeric.sat.func)
|
||||
|
||||
[1](#func-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13392)
|
||||
|
||||
In the following descriptions, an arithmetic operation
|
||||
is performed as a mathematical operation with infinite range and then
|
||||
it is determined whether the mathematical result fits into the result type[.](#func-1.sentence-1)
|
||||
|
||||
[ð](#lib:add_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T add_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[2](#func-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13404)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#func-2.sentence-1)
|
||||
|
||||
[3](#func-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13408)
|
||||
|
||||
*Returns*: If x+y is representable as a value of type T, x+y;
|
||||
otherwise, either the largest or smallest representable value of type T,
|
||||
whichever is closer to the value of x+y[.](#func-3.sentence-1)
|
||||
|
||||
[ð](#lib:sub_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T sub_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[4](#func-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13422)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#func-4.sentence-1)
|
||||
|
||||
[5](#func-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13426)
|
||||
|
||||
*Returns*: If xây is representable as a value of type T, xây;
|
||||
otherwise, either the largest or smallest representable value of type T,
|
||||
whichever is closer to the value of xây[.](#func-5.sentence-1)
|
||||
|
||||
[ð](#lib:mul_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T mul_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[6](#func-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13440)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#func-6.sentence-1)
|
||||
|
||||
[7](#func-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13444)
|
||||
|
||||
*Returns*: If x ×y is representable as a value of type T, x ×y;
|
||||
otherwise, either the largest or smallest representable value of type T,
|
||||
whichever is closer to the value of x ×y[.](#func-7.sentence-1)
|
||||
|
||||
[ð](#lib:div_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T div_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[8](#func-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13458)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#func-8.sentence-1)
|
||||
|
||||
[9](#func-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13462)
|
||||
|
||||
*Preconditions*: y != 0 is true[.](#func-9.sentence-1)
|
||||
|
||||
[10](#func-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13466)
|
||||
|
||||
*Returns*: If T is a signed integer type
|
||||
and x == numeric_limits<T>::min() && y == -1 is true,numeric_limits<T>::max(), otherwise, x / y[.](#func-10.sentence-1)
|
||||
|
||||
[11](#func-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13472)
|
||||
|
||||
*Remarks*: A function call expression
|
||||
that violates the precondition in the *Preconditions* element
|
||||
is not a core constant expression ([[expr.const]](expr.const "7.7 Constant expressions"))[.](#func-11.sentence-1)
|
||||
|
||||
#### [26.10.17.2](#cast) Casting [[numeric.sat.cast]](numeric.sat.cast)
|
||||
|
||||
[ð](#lib:saturate_cast)
|
||||
|
||||
`template<class R, class T>
|
||||
constexpr R saturate_cast(T x) noexcept;
|
||||
`
|
||||
|
||||
[1](#cast-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13488)
|
||||
|
||||
*Constraints*: R and T are signed or unsigned integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#cast-1.sentence-1)
|
||||
|
||||
[2](#cast-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13492)
|
||||
|
||||
*Returns*: If x is representable as a value of type R, x;
|
||||
otherwise, either the largest or smallest representable value of type R,
|
||||
whichever is closer to the value of x[.](#cast-2.sentence-1)
|
||||
29
cppdraft/numeric/sat/cast.md
Normal file
29
cppdraft/numeric/sat/cast.md
Normal file
@@ -0,0 +1,29 @@
|
||||
[numeric.sat.cast]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#numeric.sat.cast)
|
||||
|
||||
### 26.10.17 Saturation arithmetic [[numeric.sat]](numeric.sat#cast)
|
||||
|
||||
#### 26.10.17.2 Casting [numeric.sat.cast]
|
||||
|
||||
[ð](#lib:saturate_cast)
|
||||
|
||||
`template<class R, class T>
|
||||
constexpr R saturate_cast(T x) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13488)
|
||||
|
||||
*Constraints*: R and T are signed or unsigned integer types ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13492)
|
||||
|
||||
*Returns*: If x is representable as a value of type R, x;
|
||||
otherwise, either the largest or smallest representable value of type R,
|
||||
whichever is closer to the value of x[.](#2.sentence-1)
|
||||
110
cppdraft/numeric/sat/func.md
Normal file
110
cppdraft/numeric/sat/func.md
Normal file
@@ -0,0 +1,110 @@
|
||||
[numeric.sat.func]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#numeric.sat.func)
|
||||
|
||||
### 26.10.17 Saturation arithmetic [[numeric.sat]](numeric.sat#func)
|
||||
|
||||
#### 26.10.17.1 Arithmetic functions [numeric.sat.func]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13392)
|
||||
|
||||
In the following descriptions, an arithmetic operation
|
||||
is performed as a mathematical operation with infinite range and then
|
||||
it is determined whether the mathematical result fits into the result type[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:add_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T add_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13404)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13408)
|
||||
|
||||
*Returns*: If x+y is representable as a value of type T, x+y;
|
||||
otherwise, either the largest or smallest representable value of type T,
|
||||
whichever is closer to the value of x+y[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:sub_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T sub_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13422)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13426)
|
||||
|
||||
*Returns*: If xây is representable as a value of type T, xây;
|
||||
otherwise, either the largest or smallest representable value of type T,
|
||||
whichever is closer to the value of xây[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:mul_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T mul_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13440)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13444)
|
||||
|
||||
*Returns*: If x ×y is representable as a value of type T, x ×y;
|
||||
otherwise, either the largest or smallest representable value of type T,
|
||||
whichever is closer to the value of x ×y[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:div_sat)
|
||||
|
||||
`template<class T>
|
||||
constexpr T div_sat(T x, T y) noexcept;
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13458)
|
||||
|
||||
*Constraints*: T is a signed or unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13462)
|
||||
|
||||
*Preconditions*: y != 0 is true[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13466)
|
||||
|
||||
*Returns*: If T is a signed integer type
|
||||
and x == numeric_limits<T>::min() && y == -1 is true,numeric_limits<T>::max(), otherwise, x / y[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13472)
|
||||
|
||||
*Remarks*: A function call expression
|
||||
that violates the precondition in the *Preconditions* element
|
||||
is not a core constant expression ([[expr.const]](expr.const "7.7 Constant expressions"))[.](#11.sentence-1)
|
||||
37
cppdraft/numeric/special.md
Normal file
37
cppdraft/numeric/special.md
Normal file
@@ -0,0 +1,37 @@
|
||||
[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; };}
|
||||
Reference in New Issue
Block a user