@@ -164,3 +164,174 @@ In the event of binary arithmetic between two decimal types the result will be t
164164== 3.2.10 Note
165165
166166xref:design.adoc#non-finite-deviation[Non-finite values are supported]
167+
168+ [#operator_behavior]
169+ == Operator Behaviors
170+
171+ === Unary Plus
172+
173+ [source,c++]
174+ ----
175+ // 3.2.7 unary arithmetic operators:
176+ constexpr decimal32_t operator+(decimal32_t rhs) noexcept;
177+ constexpr decimal64_t operator+(decimal64_t rhs) noexcept;
178+ constexpr decimal128_t operator+(decimal128_t rhs) noexcept;
179+ ----
180+
181+ Returns `rhs` unmodified in all cases.
182+
183+ === Unary Minus
184+
185+ [source,c++]
186+ ----
187+ constexpr decimal32_t operator-(decimal32_t rhs) noexcept;
188+ constexpr decimal64_t operator-(decimal64_t rhs) noexcept;
189+ constexpr decimal128_t operator-(decimal128_t rhs) noexcept;
190+ ----
191+
192+ Returns negated `rhs` in all cases.
193+
194+ === Addition
195+
196+ [source,c++]
197+ ----
198+ // 3.2.8 binary arithmetic operators:
199+ // LHS and RHS can be any integer or decimal type
200+
201+ constexpr /* see 3.2.8 */ operator+(LHS lhs, decimal32_t rhs) noexcept;
202+ constexpr /* see 3.2.8 */ operator+(LHS lhs, decimal64_t rhs) noexcept;
203+ constexpr /* see 3.2.8 */ operator+(LHS lhs, decimal128_t rhs) noexcept;
204+ constexpr /* see 3.2.8 */ operator+(decimal32_t lhs, RHS rhs) noexcept;
205+ constexpr /* see 3.2.8 */ operator+(decimal64_t lhs, RHS rhs) noexcept;
206+ constexpr /* see 3.2.8 */ operator+(decimal128_t lhs, RHS rhs) noexcept;
207+ ----
208+
209+ Returns the result of `lhs + rhs` subject to:
210+
211+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
212+ . If `lhs` and `rhs` are `INF` of opposite sign, returns `QNAN`
213+ . If either `lhs` or `rhs` are `INF`, returns `INF` of same sign
214+ . If `lhs + rhs` overflows, returns `INF`
215+ . If `lhs + rhs` underflows, returns `0`
216+
217+ === Subtraction
218+
219+ [source,c++]
220+ ----
221+ // 3.2.8 binary arithmetic operators:
222+ // LHS and RHS can be any integer or decimal type
223+
224+ constexpr /* see 3.2.8 */ operator-(LHS lhs, decimal32_t rhs) noexcept;
225+ constexpr /* see 3.2.8 */ operator-(LHS lhs, decimal64_t rhs) noexcept;
226+ constexpr /* see 3.2.8 */ operator-(LHS lhs, decimal128_t rhs) noexcept;
227+ constexpr /* see 3.2.8 */ operator-(decimal32_t lhs, RHS rhs) noexcept;
228+ constexpr /* see 3.2.8 */ operator-(decimal64_t lhs, RHS rhs) noexcept;
229+ constexpr /* see 3.2.8 */ operator-(decimal128_t lhs, RHS rhs) noexcept;
230+ ----
231+
232+ Returns the result of `lhs - rhs` subject to:
233+
234+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
235+ . If `lhs` and `rhs` are `INF` of opposite sign, returns `QNAN`
236+ . If either `lhs` or `rhs` are `INF`, returns `INF` of same sign
237+ . If `lhs - rhs` overflows, returns `INF`
238+ . If `lhs - rhs` underflows, returns `0`
239+
240+ === Multiplication
241+
242+ [source,c++]
243+ ----
244+ // 3.2.8 binary arithmetic operators:
245+ // LHS and RHS can be any integer or decimal type
246+
247+ constexpr /* see 3.2.8 */ operator*(LHS lhs, decimal32_t rhs) noexcept;
248+ constexpr /* see 3.2.8 */ operator*(LHS lhs, decimal64_t rhs) noexcept;
249+ constexpr /* see 3.2.8 */ operator*(LHS lhs, decimal128_t rhs) noexcept;
250+ constexpr /* see 3.2.8 */ operator*(decimal32_t lhs, RHS rhs) noexcept;
251+ constexpr /* see 3.2.8 */ operator*(decimal64_t lhs, RHS rhs) noexcept;
252+ constexpr /* see 3.2.8 */ operator*(decimal128_t lhs, RHS rhs) noexcept;
253+ ----
254+
255+ Returns the result of `lhs * rhs` subject to:
256+
257+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
258+ . If either `lhs` or `rhs` are `INF` and the other is `0`, returns `QNAN`
259+ . If either `lhs` or `rhs` are `INF`, returns `INF` of same sign
260+ . If `lhs * rhs` overflows, returns `INF`
261+ . If `lhs * rhs` underflows, returns `0`
262+
263+ === Division
264+
265+ [source,c++]
266+ ----
267+ // 3.2.8 binary arithmetic operators:
268+ // LHS and RHS can be any integer or decimal type
269+
270+ constexpr /* see 3.2.8 */ operator/(LHS lhs, decimal32_t rhs) noexcept;
271+ constexpr /* see 3.2.8 */ operator/(LHS lhs, decimal64_t rhs) noexcept;
272+ constexpr /* see 3.2.8 */ operator/(LHS lhs, decimal128_t rhs) noexcept;
273+ constexpr /* see 3.2.8 */ operator/(decimal32_t lhs, RHS rhs) noexcept;
274+ constexpr /* see 3.2.8 */ operator/(decimal64_t lhs, RHS rhs) noexcept;
275+ constexpr /* see 3.2.8 */ operator/(decimal128_t lhs, RHS rhs) noexcept;
276+ ----
277+
278+ Returns the result of `lhs / rhs` subject to:
279+
280+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
281+ . If `lhs` is `INF`:
282+ .. Returns `QNAN` if `rhs` is `INF`
283+ .. Returns `INF` if `rhs` is not `INF`
284+ . If `rhs` is `0` returns `INF`
285+ . If `rhs` is `INF` returns `0`
286+ . If `lhs / rhs` overflows, returns `INF`
287+ . If `lhs / rhs` underflows, returns `0`
288+
289+ === Comparison Operators
290+
291+ [source, c++]
292+ ----
293+ // 3.2.9 comparison operators:
294+ // LHS and RHS can be any integer or decimal type
295+
296+ constexpr bool operator==(LHS lhs, decimal32_t rhs) noexcept;
297+ constexpr bool operator==(LHS lhs, decimal64_t rhs) noexcept;
298+ constexpr bool operator==(LHS lhs, decimal128_t rhs) noexcept;
299+ constexpr bool operator==(decimal32_t lhs, RHS rhs) noexcept;
300+ constexpr bool operator==(decimal64_t lhs, RHS rhs) noexcept;
301+ constexpr bool operator==(decimal128_t lhs, RHS rhs) noexcept;
302+ constexpr bool operator!=(LHS lhs, decimal32_t rhs) noexcept;
303+ constexpr bool operator!=(LHS lhs, decimal64_t rhs) noexcept;
304+ constexpr bool operator!=(LHS lhs, decimal128_t rhs) noexcept;
305+ constexpr bool operator!=(decimal32_t lhs, RHS rhs) noexcept;
306+ constexpr bool operator!=(decimal64_t lhs, RHS rhs) noexcept;
307+ constexpr bool operator!=(decimal128_t lhs, RHS rhs) noexcept;
308+ constexpr bool operator<(LHS lhs, decimal32_t rhs) noexcept;
309+ constexpr bool operator<(LHS lhs, decimal64_t rhs) noexcept;
310+ constexpr bool operator<(LHS lhs, decimal128_t rhs) noexcept;
311+ constexpr bool operator<(decimal32_t lhs, RHS rhs) noexcept;
312+ constexpr bool operator<(decimal64_t lhs, RHS rhs) noexcept;
313+ constexpr bool operator<(decimal128_t lhs, RHS rhs) noexcept;
314+ constexpr bool operator<=(LHS lhs, decimal32_t rhs) noexcept;
315+ constexpr bool operator<=(LHS lhs, decimal64_t rhs) noexcept;
316+ constexpr bool operator<=(LHS lhs, decimal128_t rhs) noexcept;
317+ constexpr bool operator<=(decimal32_t lhs, RHS rhs) noexcept;
318+ constexpr bool operator<=(decimal64_t lhs, RHS rhs) noexcept;
319+ constexpr bool operator<=(decimal128_t lhs, RHS rhs) noexcept;
320+ constexpr bool operator>(LHS lhs, decimal32_t rhs) noexcept;
321+ constexpr bool operator>(LHS lhs, decimal64_t rhs) noexcept;
322+ constexpr bool operator>(LHS lhs, decimal128_t rhs) noexcept;
323+ constexpr bool operator>(decimal32_t lhs, RHS rhs) noexcept;
324+ constexpr bool operator>(decimal64_t lhs, RHS rhs) noexcept;
325+ constexpr bool operator>(decimal128_t lhs, RHS rhs) noexcept;
326+ constexpr bool operator>=(LHS lhs, decimal32_t rhs) noexcept;
327+ constexpr bool operator>=(LHS lhs, decimal64_t rhs) noexcept;
328+ constexpr bool operator>=(LHS lhs, decimal128_t rhs) noexcept;
329+ constexpr bool operator>=(decimal32_t lhs, RHS rhs) noexcept;
330+ constexpr bool operator>=(decimal64_t lhs, RHS rhs) noexcept;
331+ constexpr bool operator>=(decimal128_t lhs, RHS rhs) noexcept;
332+ ----
333+
334+ Returns the result of the comparison subject to:
335+
336+ . If `lhs` or `rhs` returns `false`
337+ .. This includes the case where both `lhs` and `rhs` are `NAN`
0 commit comments