diff --git a/doc/modules/ROOT/pages/basics.adoc b/doc/modules/ROOT/pages/basics.adoc index a800fc8ec..f1016b185 100644 --- a/doc/modules/ROOT/pages/basics.adoc +++ b/doc/modules/ROOT/pages/basics.adoc @@ -17,7 +17,7 @@ Every decimal type can be constructed in a few ways: [source, c++] ---- template -constexpr decimal32_t(UnsignedInteger coefficient, Integer exponent, bool sign = false) noexcept; +constexpr decimal32_t(UnsignedInteger coefficient, Integer exponent, bool is_negative = false) noexcept; template constexpr decimal32_t(SignedInteger coefficient, Integer exponent) noexcept; diff --git a/doc/modules/ROOT/pages/decimal128_t.adoc b/doc/modules/ROOT/pages/decimal128_t.adoc index cc19d7d47..3df01be26 100644 --- a/doc/modules/ROOT/pages/decimal128_t.adoc +++ b/doc/modules/ROOT/pages/decimal128_t.adoc @@ -64,10 +64,10 @@ explicit constexpr decimal128_t(std::string_view str); #endif template -constexpr decimal128_t(UnsignedIntegral coeff, Integral exp, bool sign = false) noexcept; +constexpr decimal128_t(UnsignedIntegral coeff, Integral exp, bool is_negative = false) noexcept; template -constexpr decimal128_t(SignedIntegral coeff, Integral exp, bool sign = false) noexcept; +constexpr decimal128_t(SignedIntegral coeff, Integral exp, bool is_negative = false) noexcept; template constexpr decimal128_t& operator=(const Integeral& RHS) noexcept; diff --git a/doc/modules/ROOT/pages/decimal32_t.adoc b/doc/modules/ROOT/pages/decimal32_t.adoc index e81cf363e..caeaaa627 100644 --- a/doc/modules/ROOT/pages/decimal32_t.adoc +++ b/doc/modules/ROOT/pages/decimal32_t.adoc @@ -64,7 +64,7 @@ explicit constexpr decimal32_t(std::string_view str); #endif template -constexpr decimal32_t(UnsignedIntegral coeff, Integral exp, bool sign = false) noexcept; +constexpr decimal32_t(UnsignedIntegral coeff, Integral exp, bool is_negative = false) noexcept; template constexpr decimal32_t(SignedIntegral coeff, Integral exp) noexcept; diff --git a/doc/modules/ROOT/pages/decimal64_t.adoc b/doc/modules/ROOT/pages/decimal64_t.adoc index 6c7b886d8..fe58aefd7 100644 --- a/doc/modules/ROOT/pages/decimal64_t.adoc +++ b/doc/modules/ROOT/pages/decimal64_t.adoc @@ -64,7 +64,7 @@ explicit constexpr decimal64_t(std::string_view str); #endif template -constexpr decimal64_t(UnsignedIntegral coeff, Integral exp, bool sign = false) noexcept; +constexpr decimal64_t(UnsignedIntegral coeff, Integral exp, bool is_negative = false) noexcept; template constexpr decimal64_t(SignedIntegral coeff, Integral exp) noexcept; diff --git a/doc/modules/ROOT/pages/decimal_fast128_t.adoc b/doc/modules/ROOT/pages/decimal_fast128_t.adoc index a79457748..961f1cdf2 100644 --- a/doc/modules/ROOT/pages/decimal_fast128_t.adoc +++ b/doc/modules/ROOT/pages/decimal_fast128_t.adoc @@ -66,7 +66,7 @@ explicit constexpr decimal_fast128_t(std::string_view str); #endif template -constexpr decimal_fast128_t(UnsignedIntegral coeff, Integral exp, bool sign = false) noexcept; +constexpr decimal_fast128_t(UnsignedIntegral coeff, Integral exp, bool is_negative = false) noexcept; template constexpr decimal_fast128_t(SignedIntegral coeff, Integral exp) noexcept; diff --git a/doc/modules/ROOT/pages/decimal_fast32_t.adoc b/doc/modules/ROOT/pages/decimal_fast32_t.adoc index de2e9bdf4..ac7adf9c9 100644 --- a/doc/modules/ROOT/pages/decimal_fast32_t.adoc +++ b/doc/modules/ROOT/pages/decimal_fast32_t.adoc @@ -66,7 +66,7 @@ explicit constexpr decimal_fast32_t(std::string_view str); #endif template -constexpr decimal_fast32_t(UnsignedIntegral coeff, Integral exp, bool sign = false) noexcept; +constexpr decimal_fast32_t(UnsignedIntegral coeff, Integral exp, bool is_negative = false) noexcept; template constexpr decimal_fast32_t(SignedIntegral coeff, Integral exp) noexcept; diff --git a/doc/modules/ROOT/pages/decimal_fast64_t.adoc b/doc/modules/ROOT/pages/decimal_fast64_t.adoc index e8fd4a25a..e7002c845 100644 --- a/doc/modules/ROOT/pages/decimal_fast64_t.adoc +++ b/doc/modules/ROOT/pages/decimal_fast64_t.adoc @@ -66,7 +66,7 @@ explicit constexpr decimal_fast64_t(std::string_view str); #endif template -constexpr decimal_fast64_t(UnsignedIntegral coeff, Integral exp, bool sign = false) noexcept; +constexpr decimal_fast64_t(UnsignedIntegral coeff, Integral exp, bool is_negative = false) noexcept; template constexpr decimal_fast64_t(SignedIntegral coeff, Integral exp) noexcept; diff --git a/include/boost/decimal/decimal128_t.hpp b/include/boost/decimal/decimal128_t.hpp index 41c7bfcfd..571b4b877 100644 --- a/include/boost/decimal/decimal128_t.hpp +++ b/include/boost/decimal/decimal128_t.hpp @@ -262,7 +262,7 @@ BOOST_DECIMAL_EXPORT class decimal128_t final #else template && detail::is_integral_v, bool> = true> #endif - constexpr decimal128_t(T1 coeff, T2 exp, bool sign = false) noexcept; + constexpr decimal128_t(T1 coeff, T2 exp, bool is_negative = false) noexcept; #ifdef BOOST_DECIMAL_HAS_CONCEPTS template @@ -733,9 +733,9 @@ template #else template && detail::is_integral_v, bool>> #endif -constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool sign) noexcept +constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool is_negative) noexcept { - bits_.high = sign ? detail::d128_sign_mask : UINT64_C(0); + bits_.high = is_negative ? detail::d128_sign_mask : UINT64_C(0); // If the coeff is not in range make it so // The coefficient needs at least 110 bits so there's a good chance we don't need to @@ -747,7 +747,7 @@ constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool sign) noexcept { if (coeff > detail::d128_max_significand_value || biased_exp < 0) { - coeff_digits = detail::coefficient_rounding(coeff, exp, biased_exp, sign, detail::num_digits(coeff)); + coeff_digits = detail::coefficient_rounding(coeff, exp, biased_exp, is_negative, detail::num_digits(coeff)); } } @@ -786,19 +786,19 @@ constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool sign) noexcept { exp -= digit_delta; reduced_coeff *= detail::pow10(static_cast(digit_delta)); - *this = decimal128_t(reduced_coeff, exp, sign); + *this = decimal128_t(reduced_coeff, exp, is_negative); } else if (digit_delta < 0 && coeff_digits - digit_delta <= detail::precision_v) { const auto offset {detail::precision_v - coeff_digits}; exp -= offset; reduced_coeff *= detail::pow10(static_cast(offset)); - *this = decimal128_t(reduced_coeff, exp, sign); + *this = decimal128_t(reduced_coeff, exp, is_negative); } else { bits_ = exp < 0 ? zero : detail::d128_inf_mask; - bits_.high |= sign ? detail::d128_sign_mask : UINT64_C(0); + bits_.high |= is_negative ? detail::d128_sign_mask : UINT64_C(0); } } } diff --git a/include/boost/decimal/decimal32_t.hpp b/include/boost/decimal/decimal32_t.hpp index 18963f799..e6e296dc6 100644 --- a/include/boost/decimal/decimal32_t.hpp +++ b/include/boost/decimal/decimal32_t.hpp @@ -288,7 +288,7 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special #else template && detail::is_integral_v, bool> = true> #endif - constexpr decimal32_t(T1 coeff, T2 exp, bool sign = false) noexcept; + constexpr decimal32_t(T1 coeff, T2 exp, bool is_negative = false) noexcept; #ifdef BOOST_DECIMAL_HAS_CONCEPTS template @@ -642,12 +642,12 @@ template #else template && detail::is_integral_v, bool>> #endif -constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool sign) noexcept // NOLINT(readability-function-cognitive-complexity,misc-no-recursion) +constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool is_negative) noexcept // NOLINT(readability-function-cognitive-complexity,misc-no-recursion) { static_assert(detail::is_integral_v, "Coefficient must be an integer"); static_assert(detail::is_integral_v, "Exponent must be an integer"); - bits_ = sign ? detail::d32_sign_mask : UINT32_C(0); + bits_ = is_negative ? detail::d32_sign_mask : UINT32_C(0); // If the coeff is not in range, make it so // Only count the number of digits if we absolutely have to @@ -655,7 +655,7 @@ constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool sign) noexcept // NOLI auto biased_exp {static_cast(exp + detail::bias)}; if (coeff > detail::d32_max_significand_value || biased_exp < 0) { - coeff_digits = detail::coefficient_rounding(coeff, exp, biased_exp, sign, detail::num_digits(coeff)); + coeff_digits = detail::coefficient_rounding(coeff, exp, biased_exp, is_negative, detail::num_digits(coeff)); } auto reduced_coeff {static_cast(coeff)}; @@ -708,7 +708,7 @@ constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool sign) noexcept // NOLI { exp -= digit_delta; reduced_coeff *= detail::pow10(static_cast(digit_delta)); - *this = decimal32_t(reduced_coeff, exp, sign); + *this = decimal32_t(reduced_coeff, exp, is_negative); } else if (digit_delta < 0 && coeff_digits - digit_delta <= detail::precision) { @@ -716,13 +716,13 @@ constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool sign) noexcept // NOLI const auto offset {detail::precision - coeff_digits}; exp -= offset; reduced_coeff *= detail::pow10(static_cast(offset)); - *this = decimal32_t(reduced_coeff, exp, sign); + *this = decimal32_t(reduced_coeff, exp, is_negative); } else { // Reset the value and make sure to preserve the sign of 0/inf bits_ = exp < 0 ? UINT32_C(0) : detail::d32_inf_mask; - bits_ |= sign ? detail::d32_sign_mask : UINT32_C(0); + bits_ |= is_negative ? detail::d32_sign_mask : UINT32_C(0); } } } diff --git a/include/boost/decimal/decimal64_t.hpp b/include/boost/decimal/decimal64_t.hpp index 7391c5730..d121860ef 100644 --- a/include/boost/decimal/decimal64_t.hpp +++ b/include/boost/decimal/decimal64_t.hpp @@ -325,7 +325,7 @@ BOOST_DECIMAL_EXPORT class decimal64_t final #else template && detail::is_integral_v, bool> = true> #endif - constexpr decimal64_t(T1 coeff, T2 exp, bool sign = false) noexcept; + constexpr decimal64_t(T1 coeff, T2 exp, bool is_negative = false) noexcept; #ifdef BOOST_DECIMAL_HAS_CONCEPTS template @@ -640,16 +640,16 @@ template #else template && detail::is_integral_v, bool>> #endif -constexpr decimal64_t::decimal64_t(T1 coeff, T2 exp, bool sign) noexcept +constexpr decimal64_t::decimal64_t(T1 coeff, T2 exp, bool is_negative) noexcept { - bits_ = sign ? detail::d64_sign_mask : UINT64_C(0); + bits_ = is_negative ? detail::d64_sign_mask : UINT64_C(0); // If the coeff is not in range, make it so int coeff_digits {-1}; auto biased_exp {static_cast(exp) + detail::bias_v}; if (coeff > detail::d64_max_significand_value || biased_exp < 0) { - coeff_digits = detail::coefficient_rounding(coeff, exp, biased_exp, sign, detail::num_digits(coeff)); + coeff_digits = detail::coefficient_rounding(coeff, exp, biased_exp, is_negative, detail::num_digits(coeff)); } auto reduced_coeff {static_cast(coeff)}; @@ -702,20 +702,20 @@ constexpr decimal64_t::decimal64_t(T1 coeff, T2 exp, bool sign) noexcept { exp -= digit_delta; reduced_coeff *= detail::pow10(static_cast(digit_delta)); - *this = decimal64_t(reduced_coeff, exp, sign); + *this = decimal64_t(reduced_coeff, exp, is_negative); } else if (digit_delta < 0 && coeff_digits - digit_delta <= detail::precision_v) { const auto offset {detail::precision_v - coeff_digits}; exp -= offset; reduced_coeff *= detail::pow10(static_cast(offset)); - *this = decimal64_t(reduced_coeff, exp, sign); + *this = decimal64_t(reduced_coeff, exp, is_negative); } else { // Reset the value and make sure to preserve the sign of 0/inf bits_ = exp < 0 ? UINT64_C(0) : detail::d64_inf_mask; - bits_ |= sign ? detail::d64_sign_mask : UINT64_C(0); + bits_ |= is_negative ? detail::d64_sign_mask : UINT64_C(0); } } } diff --git a/include/boost/decimal/decimal_fast128_t.hpp b/include/boost/decimal/decimal_fast128_t.hpp index cf32914c2..953eaaaa8 100644 --- a/include/boost/decimal/decimal_fast128_t.hpp +++ b/include/boost/decimal/decimal_fast128_t.hpp @@ -197,7 +197,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final #else template && detail::is_integral_v, bool> = true> #endif - constexpr decimal_fast128_t(T1 coeff, T2 exp, bool sign = false) noexcept; + constexpr decimal_fast128_t(T1 coeff, T2 exp, bool is_negative = false) noexcept; #ifdef BOOST_DECIMAL_HAS_CONCEPTS template @@ -471,17 +471,17 @@ template #else template && detail::is_integral_v, bool>> #endif -constexpr decimal_fast128_t::decimal_fast128_t(T1 coeff, T2 exp, bool sign) noexcept +constexpr decimal_fast128_t::decimal_fast128_t(T1 coeff, T2 exp, bool is_negative) noexcept { using minimum_coefficient_size = std::conditional_t<(sizeof(T1) > sizeof(significand_type)), T1, significand_type>; minimum_coefficient_size min_coeff {coeff}; - sign_ = sign; + sign_ = is_negative; // Normalize the significand in the constructor, so we don't have // to calculate the number of digits for operations - detail::normalize(min_coeff, exp, sign); + detail::normalize(min_coeff, exp, is_negative); significand_ = static_cast(min_coeff); diff --git a/include/boost/decimal/decimal_fast32_t.hpp b/include/boost/decimal/decimal_fast32_t.hpp index 113241b92..4263b5be5 100644 --- a/include/boost/decimal/decimal_fast32_t.hpp +++ b/include/boost/decimal/decimal_fast32_t.hpp @@ -193,7 +193,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final constexpr decimal_fast32_t() noexcept = default; template && detail::is_integral_v, bool> = true> - constexpr decimal_fast32_t(T1 coeff, T2 exp, bool sign = false) noexcept; + constexpr decimal_fast32_t(T1 coeff, T2 exp, bool is_negative = false) noexcept; template && detail::is_integral_v, bool> = true> constexpr decimal_fast32_t(T1, T2, bool) noexcept { static_assert(detail::is_unsigned_v, "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}"); } @@ -461,16 +461,16 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final }; template && detail::is_integral_v, bool>> -constexpr decimal_fast32_t::decimal_fast32_t(T1 coeff, T2 exp, bool sign) noexcept +constexpr decimal_fast32_t::decimal_fast32_t(T1 coeff, T2 exp, bool is_negative) noexcept { using minimum_coefficient_size = std::conditional_t<(sizeof(T1) > sizeof(significand_type)), T1, significand_type>; minimum_coefficient_size min_coeff {coeff}; - sign_ = sign; + sign_ = is_negative; // Normalize in the constructor, so we never have to worry about it again - detail::normalize(min_coeff, exp, sign); + detail::normalize(min_coeff, exp, is_negative); significand_ = static_cast(min_coeff); diff --git a/include/boost/decimal/decimal_fast64_t.hpp b/include/boost/decimal/decimal_fast64_t.hpp index 5474e43ca..70026c7dd 100644 --- a/include/boost/decimal/decimal_fast64_t.hpp +++ b/include/boost/decimal/decimal_fast64_t.hpp @@ -204,7 +204,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final #else template && detail::is_integral_v, bool> = true> #endif - constexpr decimal_fast64_t(T1 coeff, T2 exp, bool sign = false) noexcept; + constexpr decimal_fast64_t(T1 coeff, T2 exp, bool is_negative = false) noexcept; #ifdef BOOST_DECIMAL_HAS_CONCEPTS template @@ -465,16 +465,16 @@ template #else template && detail::is_integral_v, bool>> #endif -constexpr decimal_fast64_t::decimal_fast64_t(T1 coeff, T2 exp, bool sign) noexcept +constexpr decimal_fast64_t::decimal_fast64_t(T1 coeff, T2 exp, bool is_negative) noexcept { using minimum_coefficient_size = std::conditional_t<(sizeof(T1) > sizeof(significand_type)), T1, significand_type>; minimum_coefficient_size min_coeff {coeff}; - sign_ = sign; + sign_ = is_negative; // Normalize the value, so we don't have to worry about it with operations - detail::normalize(min_coeff, exp, sign); + detail::normalize(min_coeff, exp, is_negative); significand_ = static_cast(min_coeff);