Skip to content

Commit 2bc8e5f

Browse files
authored
Merge pull request #1269 from cppalliance/more_fast
Improve fast type documentation
2 parents f43cee2 + 11d4c45 commit 2bc8e5f

File tree

5 files changed

+396
-1
lines changed

5 files changed

+396
-1
lines changed

doc/modules/ROOT/nav.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
** xref:cmath.adoc#basic_cmath_ops[Basic Operations]
4040
** xref:cmath.adoc#cmath_exp[Exponential Functions]
4141
** xref:cmath.adoc#cmath_power_funcs[Power Functions]
42-
** xref:cmath.adoc#cmath_trig_funcs[Trigonometic Functions]
42+
** xref:cmath.adoc#cmath_trig_funcs[Trigonometric Functions]
4343
** xref:cmath.adoc#cmath_hyperbolic_funcs[Hyperbolic Functions]
4444
** xref:cmath.adoc#cmath_error_funcs[Error and Gamma Functions]
4545
** xref:cmath.adoc#cmath_nearest_int[Nearest Integer Floating Point]

doc/modules/ROOT/pages/decimal_fast128_t.adoc

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,144 @@ explicit constexpr operator std::float64_t() const noexcept;
108108
explicit constexpr operator std::bfloat16_t() const noexcept;
109109
110110
explicit constexpr operator decimal32_t() const noexcept;
111+
explicit constexpr operator decimal_fast32_t() const noexcept;
111112
explicit constexpr operator decimal64_t() const noexcept;
113+
explicit constexpr operator decimal_fast64_t() const noexcept;
114+
explicit constexpr operator decimal128_t() const noexcept;
112115
113116
}; // class decimal_fast128_t
114117
115118
} //namespace decimal
116119
} //namespace boost
117120
118121
----
122+
123+
124+
== Operator Behavior
125+
126+
=== Construction to and from binary floating-point type
127+
128+
[source, c++]
129+
----
130+
// 3.2.2.2 Conversion from floating-point type
131+
template <typename Float>
132+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t(Float val) noexcept;
133+
134+
// 3.2.6 Conversion to floating-point type
135+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
136+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
137+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
138+
139+
// If C++23 and <stdfloat> are available
140+
explicit constexpr operator std::float16_t() const noexcept;
141+
explicit constexpr operator std::float32_t() const noexcept;
142+
explicit constexpr operator std::float64_t() const noexcept;
143+
explicit constexpr operator std::bfloat16_t() const noexcept;
144+
----
145+
146+
See: xref:binary_floating_conversions.adoc[]
147+
148+
=== Construction From Integral Type
149+
150+
[source,c++]
151+
----
152+
// 3.2.2.3 Conversion from integral type
153+
template <typename Integer>
154+
explicit constexpr decimal_fast128_t(Integer val) noexcept;
155+
----
156+
157+
Constructs a decimal value subject to the current rounding mode (if necessary).
158+
159+
=== Construction From String
160+
161+
[source,c++]
162+
----
163+
// Extension: Construction from (c)string
164+
explicit constexpr decimal_fast128_t(const char* str);
165+
166+
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
167+
explicit inline decimal_fast128_t(const std::string& str);
168+
#else
169+
explicit constexpr decimal_fast128_t(std::string_view str);
170+
#endif
171+
----
172+
173+
Constructs a decimal value that matches `str` subject to:
174+
175+
. If `str` is a `nullptr` or of length 0 either:
176+
.. `throw std::runtime_error`
177+
.. Constructs a `QNAN` in a no exception environment
178+
. If `str` is an invalid string either:
179+
.. `throw std::runtime_error`
180+
.. Constructs a `QNAN` in a no exception environment
181+
. On overflow constructs `INF`
182+
. On underflow constructs `0`
183+
. Rounds value represented by `str` according to current rounding mode
184+
185+
=== Conversion to Integral Type
186+
187+
[source,c++]
188+
----
189+
// 3.2.2.4 Conversion to integral type
190+
191+
explicit constexpr operator int() const noexcept;
192+
explicit constexpr operator unsigned() const noexcept;
193+
explicit constexpr operator long() const noexcept;
194+
explicit constexpr operator unsigned long() const noexcept;
195+
explicit constexpr operator long long() const noexcept;
196+
explicit constexpr operator unsigned long long() const noexcept;
197+
----
198+
199+
Constructs an integer representation of the decimal value subject to:
200+
201+
. If the decimal value is `INF` returns `std::numeric_limits<IntegerType>::max()`
202+
. If the decimal value is `NAN` returns `std::numeric_limits<IntegerType>::max()`
203+
. If the decimal value exceeds the range of the `IntegerType` returns `std::numeric_limits<IntegerType>::max()`
204+
205+
=== Increment and Decrement Operators
206+
207+
[source,c++]
208+
----
209+
// 3.2.2.5 increment and decrement operators:
210+
constexpr decimal_fast128_t& operator++();
211+
constexpr decimal_fast128_t operator++(int);
212+
constexpr decimal_fast128_t& operator--();
213+
constexpr decimal_fast128_t operator--(int);
214+
----
215+
216+
Increments/Decrements the decimal value subject to:
217+
218+
. If the decimal value is `NAN` returns `QNAN`
219+
. If the decimal value is `INF` returns `INF`
220+
221+
=== Compound Operators
222+
223+
[source, c++]
224+
----
225+
// 3.2.2.6 compound assignment:
226+
constexpr decimal_fast128_t& operator+=(RHS rhs);
227+
constexpr decimal_fast128_t& operator-=(RHS rhs);
228+
constexpr decimal_fast128_t& operator*=(RHS rhs);
229+
constexpr decimal_fast128_t& operator/=(RHS rhs);
230+
----
231+
232+
Matches the behavior of xref:generic_decimal.adoc#operator_behavior[addition, subtraction, multiplication, and division].
233+
234+
=== Conversion to Other Decimal Types
235+
236+
[source,c++]
237+
----
238+
explicit constexpr operator decimal32_t() const noexcept;
239+
explicit constexpr operator decimal_fast32_t() const noexcept;
240+
explicit constexpr operator decimal64_t() const noexcept;
241+
explicit constexpr operator decimal_fast64_t() const noexcept;
242+
explicit constexpr operator decimal128_t() const noexcept;
243+
----
244+
245+
Conversion to `decimal128_t` is lossless in all cases.
246+
247+
Conversion to any other decimal type is subject to:
248+
249+
. Current rounding mode if the number of digits exceeds the precision of the target type.
250+
. Overflow constructs `INF`.
251+
. Underflow constructs `0`.

doc/modules/ROOT/pages/decimal_fast32_t.adoc

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,139 @@ explicit constexpr operator std::float32_t() const noexcept;
107107
explicit constexpr operator std::float64_t() const noexcept;
108108
explicit constexpr operator std::bfloat16_t() const noexcept;
109109
110+
explicit constexpr operator decimal32_t() const noexcept;
110111
explicit constexpr operator decimal64_t() const noexcept;
112+
explicit constexpr operator decimal_fast64_t() const noexcept;
111113
explicit constexpr operator decimal128_t() const noexcept;
114+
explicit constexpr operator decimal_fast128_t() const noexcept;
112115
113116
}; // class decimal_fast32_t
114117
115118
} //namespace decimal
116119
} //namespace boost
117120
118121
----
122+
123+
== Operator Behavior
124+
125+
=== Construction to and from binary floating-point type
126+
127+
[source, c++]
128+
----
129+
// 3.2.2.2 Conversion from floating-point type
130+
template <typename Float>
131+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t(Float val) noexcept;
132+
133+
// 3.2.6 Conversion to floating-point type
134+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator float() const noexcept;
135+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator double() const noexcept;
136+
explicit BOOST_DECIMAL_CXX20_CONSTEXPR operator long double() const noexcept;
137+
138+
// If C++23 and <stdfloat> are available
139+
explicit constexpr operator std::float16_t() const noexcept;
140+
explicit constexpr operator std::float32_t() const noexcept;
141+
explicit constexpr operator std::float64_t() const noexcept;
142+
explicit constexpr operator std::bfloat16_t() const noexcept;
143+
----
144+
145+
See: xref:binary_floating_conversions.adoc[]
146+
147+
=== Construction From Integral Type
148+
149+
[source,c++]
150+
----
151+
// 3.2.2.3 Conversion from integral type
152+
template <typename Integer>
153+
explicit constexpr decimal_fast32_t(Integer val) noexcept;
154+
----
155+
156+
Constructs a decimal value subject to the current rounding mode (if necessary).
157+
158+
=== Construction From String
159+
160+
[source,c++]
161+
----
162+
// Extension: Construction from (c)string
163+
explicit constexpr decimal_fast32_t(const char* str);
164+
165+
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
166+
explicit inline decimal_fast32_t(const std::string& str);
167+
#else
168+
explicit constexpr decimal_fast32_t(std::string_view str);
169+
#endif
170+
----
171+
172+
Constructs a decimal value that matches `str` subject to:
173+
174+
. If `str` is a `nullptr` or of length 0 either:
175+
.. `throw std::runtime_error`
176+
.. Constructs a `QNAN` in a no exception environment
177+
. If `str` is an invalid string either:
178+
.. `throw std::runtime_error`
179+
.. Constructs a `QNAN` in a no exception environment
180+
. On overflow constructs `INF`
181+
. On underflow constructs `0`
182+
. Rounds value represented by `str` according to current rounding mode
183+
184+
=== Conversion to Integral Type
185+
186+
[source,c++]
187+
----
188+
// 3.2.2.4 Conversion to integral type
189+
190+
explicit constexpr operator int() const noexcept;
191+
explicit constexpr operator unsigned() const noexcept;
192+
explicit constexpr operator long() const noexcept;
193+
explicit constexpr operator unsigned long() const noexcept;
194+
explicit constexpr operator long long() const noexcept;
195+
explicit constexpr operator unsigned long long() const noexcept;
196+
----
197+
198+
Constructs an integer representation of the decimal value subject to:
199+
200+
. If the decimal value is `INF` returns `std::numeric_limits<IntegerType>::max()`
201+
. If the decimal value is `NAN` returns `std::numeric_limits<IntegerType>::max()`
202+
. If the decimal value exceeds the range of the `IntegerType` returns `std::numeric_limits<IntegerType>::max()`
203+
204+
=== Increment and Decrement Operators
205+
206+
[source,c++]
207+
----
208+
// 3.2.2.5 increment and decrement operators:
209+
constexpr decimal_fast32_t& operator++();
210+
constexpr decimal_fast32_t operator++(int);
211+
constexpr decimal_fast32_t& operator--();
212+
constexpr decimal_fast32_t operator--(int);
213+
----
214+
215+
Increments/Decrements the decimal value subject to:
216+
217+
. If the decimal value is `NAN` returns `QNAN`
218+
. If the decimal value is `INF` returns `INF`
219+
220+
=== Compound Operators
221+
222+
[source, c++]
223+
----
224+
// 3.2.2.6 compound assignment:
225+
constexpr decimal_fast32_t& operator+=(RHS rhs);
226+
constexpr decimal_fast32_t& operator-=(RHS rhs);
227+
constexpr decimal_fast32_t& operator*=(RHS rhs);
228+
constexpr decimal_fast32_t& operator/=(RHS rhs);
229+
----
230+
231+
Matches the behavior of xref:generic_decimal.adoc#operator_behavior[addition, subtraction, multiplication, and division].
232+
233+
=== Conversion to Other Decimal Types
234+
235+
[source,c++]
236+
----
237+
explicit constexpr operator decimal32_t() const noexcept;
238+
explicit constexpr operator decimal64_t() const noexcept;
239+
explicit constexpr operator decimal_fast64_t() const noexcept;
240+
explicit constexpr operator decimal128_t() const noexcept;
241+
explicit constexpr operator decimal_fast128_t() const noexcept;
242+
----
243+
244+
Losslessly converts the current decimal value to other decimal type.
245+

0 commit comments

Comments
 (0)