|
41 | 41 | #include <boost/decimal/detail/to_chars_result.hpp> |
42 | 42 | #include <boost/decimal/detail/chars_format.hpp> |
43 | 43 | #include <boost/decimal/detail/from_string.hpp> |
| 44 | +#include <boost/decimal/detail/construction_sign.hpp> |
44 | 45 |
|
45 | 46 | #ifndef BOOST_DECIMAL_BUILD_MODULE |
46 | 47 | #include <limits> |
@@ -211,7 +212,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final |
211 | 212 | constexpr decimal_fast32_t() noexcept = default; |
212 | 213 |
|
213 | 214 | template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true> |
214 | | - constexpr decimal_fast32_t(T1 coeff, T2 exp, bool is_negative = false) noexcept; |
| 215 | + constexpr decimal_fast32_t(T1 coeff, T2 exp, detail::construction_sign_wrapper resultant_sign = construction_sign::positive) noexcept; |
215 | 216 |
|
216 | 217 | template <typename T1, typename T2, std::enable_if_t<!detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true> |
217 | 218 | constexpr decimal_fast32_t(T1, T2, bool) noexcept { static_assert(detail::is_unsigned_v<T1>, "Construction from signed integer, exponent, and sign is ambiguous, so it is disallowed. You must use an Unsigned Integer for the coefficient to construct from {coefficient, exponent, sign}"); } |
@@ -479,12 +480,13 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final |
479 | 480 | }; |
480 | 481 |
|
481 | 482 | template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool>> |
482 | | -constexpr decimal_fast32_t::decimal_fast32_t(T1 coeff, T2 exp, bool is_negative) noexcept |
| 483 | +constexpr decimal_fast32_t::decimal_fast32_t(T1 coeff, T2 exp, const detail::construction_sign_wrapper resultant_sign) noexcept |
483 | 484 | { |
484 | 485 | using minimum_coefficient_size = std::conditional_t<(sizeof(T1) > sizeof(significand_type)), T1, significand_type>; |
485 | 486 |
|
486 | 487 | minimum_coefficient_size min_coeff {coeff}; |
487 | 488 |
|
| 489 | + const auto is_negative {static_cast<bool>(resultant_sign)}; |
488 | 490 | sign_ = is_negative; |
489 | 491 |
|
490 | 492 | // Normalize in the constructor, so we never have to worry about it again |
@@ -1578,7 +1580,7 @@ class numeric_limits_impl32f |
1578 | 1580 | // Member functions |
1579 | 1581 | static constexpr auto (min) () -> boost::decimal::decimal_fast32_t { return {UINT32_C(1), min_exponent}; } |
1580 | 1582 | static constexpr auto (max) () -> boost::decimal::decimal_fast32_t { return {UINT32_C(9'999'999), max_exponent - digits + 1}; } |
1581 | | - static constexpr auto lowest () -> boost::decimal::decimal_fast32_t { return {UINT32_C(9'999'999), max_exponent - digits + 1, true}; } |
| 1583 | + static constexpr auto lowest () -> boost::decimal::decimal_fast32_t { return {UINT32_C(9'999'999), max_exponent - digits + 1, construction_sign::negative}; } |
1582 | 1584 | static constexpr auto epsilon () -> boost::decimal::decimal_fast32_t { return {UINT32_C(1), -digits + 1}; } |
1583 | 1585 | static constexpr auto round_error () -> boost::decimal::decimal_fast32_t { return epsilon(); } |
1584 | 1586 | static constexpr auto infinity () -> boost::decimal::decimal_fast32_t { return boost::decimal::direct_init(boost::decimal::detail::d32_fast_inf, UINT8_C((0))); } |
|
0 commit comments