@@ -74,9 +74,9 @@ namespace decimal {
7474
7575class decimal_fast32_t;
7676
77- class decimal64_t ;
77+ class decimal_fast64_t ;
7878
79- class decimal128_t ;
79+ class decimal_fast128_t ;
8080
8181// 3.2.7 unary arithmetic operators:
8282constexpr decimal_fast32_t operator+(decimal_fast32_t rhs) noexcept;
@@ -208,6 +208,178 @@ decimal_fast128_t d);
208208----
209209
210210=== 3.2.8 Note
211- In the event of binary arithmetic between a non-decimal type and a decimal type the arithmetic will occur between the native types, and the result will be returned as the same type as the decimal operand. (e.g. decimal32_t * uint64_t -> decimal32_t )
211+ In the event of binary arithmetic between a non-decimal type and a decimal type the arithmetic will occur between the native types, and the result will be returned as the same type as the decimal operand. (e.g. decimal_fast32_t * uint64_t -> decimal_fast32_t )
212212
213- In the event of binary arithmetic between two decimal types the result will be the higher precision type of the two (e.g. decimal64_t + decimal32_t -> decimal64_t)
213+ In the event of binary arithmetic between two decimal types the result will be the higher precision type of the two (e.g. decimal64_t + decimal_fast32_t -> decimal64_t)
214+
215+
216+ [#fast_operator_behavior]
217+ == Operator Behaviors
218+
219+ === Unary Plus
220+
221+ [source,c++]
222+ ----
223+ // 3.2.7 unary arithmetic operators:
224+ constexpr decimal_fast32_t operator+(decimal_fast32_t rhs) noexcept;
225+ constexpr decimal_fast64_t operator+(decimal_fast64_t rhs) noexcept;
226+ constexpr decimal_fast128_t operator+(decimal_fast128_t rhs) noexcept;
227+ ----
228+
229+ Returns `rhs` unmodified in all cases.
230+
231+ === Unary Minus
232+
233+ [source,c++]
234+ ----
235+ constexpr decimal_fast32_t operator-(decimal_fast32_t rhs) noexcept;
236+ constexpr decimal_fast64_t operator-(decimal_fast64_t rhs) noexcept;
237+ constexpr decimal_fast128_t operator-(decimal_fast128_t rhs) noexcept;
238+ ----
239+
240+ Returns negated `rhs` in all cases.
241+
242+ === Addition
243+
244+ [source,c++]
245+ ----
246+ // 3.2.8 binary arithmetic operators:
247+ // LHS and RHS can be any integer or decimal type
248+
249+ constexpr /* see 3.2.8 */ operator+(LHS lhs, decimal_fast32_t rhs) noexcept;
250+ constexpr /* see 3.2.8 */ operator+(LHS lhs, decimal_fast64_t rhs) noexcept;
251+ constexpr /* see 3.2.8 */ operator+(LHS lhs, decimal_fast128_t rhs) noexcept;
252+ constexpr /* see 3.2.8 */ operator+(decimal_fast32_t lhs, RHS rhs) noexcept;
253+ constexpr /* see 3.2.8 */ operator+(decimal_fast64_t lhs, RHS rhs) noexcept;
254+ constexpr /* see 3.2.8 */ operator+(decimal_fast128_t lhs, RHS rhs) noexcept;
255+ ----
256+
257+ Returns the result of `lhs + rhs` subject to:
258+
259+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
260+ . If `lhs` and `rhs` are `INF` of opposite sign, returns `QNAN`
261+ . If either `lhs` or `rhs` are `INF`, returns `INF` of same sign
262+ . If `lhs + rhs` overflows, returns `INF`
263+ . If `lhs + rhs` underflows, returns `0`
264+
265+ === Subtraction
266+
267+ [source,c++]
268+ ----
269+ // 3.2.8 binary arithmetic operators:
270+ // LHS and RHS can be any integer or decimal type
271+
272+ constexpr /* see 3.2.8 */ operator-(LHS lhs, decimal_fast32_t rhs) noexcept;
273+ constexpr /* see 3.2.8 */ operator-(LHS lhs, decimal_fast64_t rhs) noexcept;
274+ constexpr /* see 3.2.8 */ operator-(LHS lhs, decimal_fast128_t rhs) noexcept;
275+ constexpr /* see 3.2.8 */ operator-(decimal_fast32_t lhs, RHS rhs) noexcept;
276+ constexpr /* see 3.2.8 */ operator-(decimal_fast64_t lhs, RHS rhs) noexcept;
277+ constexpr /* see 3.2.8 */ operator-(decimal_fast128_t lhs, RHS rhs) noexcept;
278+ ----
279+
280+ Returns the result of `lhs - rhs` subject to:
281+
282+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
283+ . If `lhs` and `rhs` are `INF` of opposite sign, returns `QNAN`
284+ . If either `lhs` or `rhs` are `INF`, returns `INF` of same sign
285+ . If `lhs - rhs` overflows, returns `INF`
286+ . If `lhs - rhs` underflows, returns `0`
287+
288+ === Multiplication
289+
290+ [source,c++]
291+ ----
292+ // 3.2.8 binary arithmetic operators:
293+ // LHS and RHS can be any integer or decimal type
294+
295+ constexpr /* see 3.2.8 */ operator*(LHS lhs, decimal_fast32_t rhs) noexcept;
296+ constexpr /* see 3.2.8 */ operator*(LHS lhs, decimal_fast64_t rhs) noexcept;
297+ constexpr /* see 3.2.8 */ operator*(LHS lhs, decimal_fast128_t rhs) noexcept;
298+ constexpr /* see 3.2.8 */ operator*(decimal_fast32_t lhs, RHS rhs) noexcept;
299+ constexpr /* see 3.2.8 */ operator*(decimal_fast64_t lhs, RHS rhs) noexcept;
300+ constexpr /* see 3.2.8 */ operator*(decimal_fast128_t lhs, RHS rhs) noexcept;
301+ ----
302+
303+ Returns the result of `lhs * rhs` subject to:
304+
305+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
306+ . If either `lhs` or `rhs` are `INF` and the other is `0`, returns `QNAN`
307+ . If either `lhs` or `rhs` are `INF`, returns `INF` of same sign
308+ . If `lhs * rhs` overflows, returns `INF`
309+ . If `lhs * rhs` underflows, returns `0`
310+
311+ === Division
312+
313+ [source,c++]
314+ ----
315+ // 3.2.8 binary arithmetic operators:
316+ // LHS and RHS can be any integer or decimal type
317+
318+ constexpr /* see 3.2.8 */ operator/(LHS lhs, decimal_fast32_t rhs) noexcept;
319+ constexpr /* see 3.2.8 */ operator/(LHS lhs, decimal_fast64_t rhs) noexcept;
320+ constexpr /* see 3.2.8 */ operator/(LHS lhs, decimal_fast128_t rhs) noexcept;
321+ constexpr /* see 3.2.8 */ operator/(decimal_fast32_t lhs, RHS rhs) noexcept;
322+ constexpr /* see 3.2.8 */ operator/(decimal_fast64_t lhs, RHS rhs) noexcept;
323+ constexpr /* see 3.2.8 */ operator/(decimal_fast128_t lhs, RHS rhs) noexcept;
324+ ----
325+
326+ Returns the result of `lhs / rhs` subject to:
327+
328+ . If either `lhs` or `rhs` are `NAN`, returns `QNAN`
329+ . If `lhs` is `INF`:
330+ .. Returns `QNAN` if `rhs` is `INF`
331+ .. Returns `INF` if `rhs` is not `INF`
332+ . If `rhs` is `0` returns `INF`
333+ . If `rhs` is `INF` returns `0`
334+ . If `lhs / rhs` overflows, returns `INF`
335+ . If `lhs / rhs` underflows, returns `0`
336+
337+ === Comparison Operators
338+
339+ [source, c++]
340+ ----
341+ // 3.2.9 comparison operators:
342+ // LHS and RHS can be any integer or decimal type
343+
344+ constexpr bool operator==(LHS lhs, decimal_fast32_t rhs) noexcept;
345+ constexpr bool operator==(LHS lhs, decimal_fast64_t rhs) noexcept;
346+ constexpr bool operator==(LHS lhs, decimal_fast128_t rhs) noexcept;
347+ constexpr bool operator==(decimal_fast32_t lhs, RHS rhs) noexcept;
348+ constexpr bool operator==(decimal_fast64_t lhs, RHS rhs) noexcept;
349+ constexpr bool operator==(decimal_fast128_t lhs, RHS rhs) noexcept;
350+ constexpr bool operator!=(LHS lhs, decimal_fast32_t rhs) noexcept;
351+ constexpr bool operator!=(LHS lhs, decimal_fast64_t rhs) noexcept;
352+ constexpr bool operator!=(LHS lhs, decimal_fast128_t rhs) noexcept;
353+ constexpr bool operator!=(decimal_fast32_t lhs, RHS rhs) noexcept;
354+ constexpr bool operator!=(decimal_fast64_t lhs, RHS rhs) noexcept;
355+ constexpr bool operator!=(decimal_fast128_t lhs, RHS rhs) noexcept;
356+ constexpr bool operator<(LHS lhs, decimal_fast32_t rhs) noexcept;
357+ constexpr bool operator<(LHS lhs, decimal_fast64_t rhs) noexcept;
358+ constexpr bool operator<(LHS lhs, decimal_fast128_t rhs) noexcept;
359+ constexpr bool operator<(decimal_fast32_t lhs, RHS rhs) noexcept;
360+ constexpr bool operator<(decimal_fast64_t lhs, RHS rhs) noexcept;
361+ constexpr bool operator<(decimal_fast128_t lhs, RHS rhs) noexcept;
362+ constexpr bool operator<=(LHS lhs, decimal_fast32_t rhs) noexcept;
363+ constexpr bool operator<=(LHS lhs, decimal_fast64_t rhs) noexcept;
364+ constexpr bool operator<=(LHS lhs, decimal_fast128_t rhs) noexcept;
365+ constexpr bool operator<=(decimal_fast32_t lhs, RHS rhs) noexcept;
366+ constexpr bool operator<=(decimal_fast64_t lhs, RHS rhs) noexcept;
367+ constexpr bool operator<=(decimal_fast128_t lhs, RHS rhs) noexcept;
368+ constexpr bool operator>(LHS lhs, decimal_fast32_t rhs) noexcept;
369+ constexpr bool operator>(LHS lhs, decimal_fast64_t rhs) noexcept;
370+ constexpr bool operator>(LHS lhs, decimal_fast128_t rhs) noexcept;
371+ constexpr bool operator>(decimal_fast32_t lhs, RHS rhs) noexcept;
372+ constexpr bool operator>(decimal_fast64_t lhs, RHS rhs) noexcept;
373+ constexpr bool operator>(decimal_fast128_t lhs, RHS rhs) noexcept;
374+ constexpr bool operator>=(LHS lhs, decimal_fast32_t rhs) noexcept;
375+ constexpr bool operator>=(LHS lhs, decimal_fast64_t rhs) noexcept;
376+ constexpr bool operator>=(LHS lhs, decimal_fast128_t rhs) noexcept;
377+ constexpr bool operator>=(decimal_fast32_t lhs, RHS rhs) noexcept;
378+ constexpr bool operator>=(decimal_fast64_t lhs, RHS rhs) noexcept;
379+ constexpr bool operator>=(decimal_fast128_t lhs, RHS rhs) noexcept;
380+ ----
381+
382+ Returns the result of the comparison subject to:
383+
384+ . If `lhs` or `rhs` returns `false`
385+ .. This includes the case where both `lhs` and `rhs` are `NAN`
0 commit comments