@@ -16,21 +16,33 @@ Every decimal type can be constructed in a few ways:
1616
1717[source, c++]
1818----
19+ namespace boost {
20+ namespace decimal {
21+
22+ enum class construction_sign
23+ {
24+ negative,
25+ positive
26+ };
27+
1928template <typename UnsignedInteger, typename Integer>
20- constexpr decimal32_t(UnsignedInteger coefficient, Integer exponent, bool is_negative = false ) noexcept;
29+ constexpr decimal32_t(UnsignedInteger coefficient, Integer exponent, construction_sign resultant_sign = construction_sign::positive ) noexcept;
2130
2231template <typename SignedInteger, typename Integer>
2332constexpr decimal32_t(SignedInteger coefficient, Integer exponent) noexcept;
33+
34+ } // namespace decimal
35+ } // namespace boost
2436----
2537
2638As you can see you are either allowed to pass a signed integer, or specify the signedness of the resulting number, but not both.
27- This is designed to reduce confusion (e.g. what would be the resulting sign of `{-3, 0, true }`?)
39+ This is designed to reduce confusion (e.g. what would be the resulting sign of `{-3, 0, construction_sign::negative }`?)
2840
2941[souce, c++]
3042----
3143boost::decimal::decimal32_t a {1, 1}; // constructs 1e1 = 10
3244boost::decimal::decimal32_t b {-2, -1}; // constructs -2e-2 or -0.2
33- boost::decimal::decimal32_t c {2U, -1, true }; // also constructs -2e-1 or -0.2 (Note: The coefficient must be an unsigned type)
45+ boost::decimal::decimal32_t c {2U, -1, construction_sign::negative }; // also constructs -2e-1 or -0.2 (Note: The coefficient must be an unsigned type)
3446boost::decimal::decimal32_t e {5, 5}; // constructs 5x10^5
3547boost::decimal::decimal32_t f {1234, -3} // constructs 1.234 or 1234x10^-3
3648----
0 commit comments