Skip to content

Commit a2e3beb

Browse files
committed
Add member operator behavior for decimal_fast32_t
1 parent 4917e18 commit a2e3beb

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

doc/modules/ROOT/pages/decimal_fast32_t.adoc

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

0 commit comments

Comments
 (0)