Skip to content

Commit 9bef85e

Browse files
committed
Re-name constructor parameter to reduce confusion
1 parent 7cfb824 commit 9bef85e

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

include/boost/decimal/decimal128_t.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
262262
#else
263263
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true>
264264
#endif
265-
constexpr decimal128_t(T1 coeff, T2 exp, bool sign = false) noexcept;
265+
constexpr decimal128_t(T1 coeff, T2 exp, bool is_negative = false) noexcept;
266266

267267
#ifdef BOOST_DECIMAL_HAS_CONCEPTS
268268
template <BOOST_DECIMAL_SIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
@@ -733,9 +733,9 @@ template <BOOST_DECIMAL_UNSIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
733733
#else
734734
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool>>
735735
#endif
736-
constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool sign) noexcept
736+
constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool is_negative) noexcept
737737
{
738-
bits_.high = sign ? detail::d128_sign_mask : UINT64_C(0);
738+
bits_.high = is_negative ? detail::d128_sign_mask : UINT64_C(0);
739739

740740
// If the coeff is not in range make it so
741741
// 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
747747
{
748748
if (coeff > detail::d128_max_significand_value || biased_exp < 0)
749749
{
750-
coeff_digits = detail::coefficient_rounding<decimal128_t>(coeff, exp, biased_exp, sign, detail::num_digits(coeff));
750+
coeff_digits = detail::coefficient_rounding<decimal128_t>(coeff, exp, biased_exp, is_negative, detail::num_digits(coeff));
751751
}
752752
}
753753

@@ -786,19 +786,19 @@ constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool sign) noexcept
786786
{
787787
exp -= digit_delta;
788788
reduced_coeff *= detail::pow10(static_cast<significand_type>(digit_delta));
789-
*this = decimal128_t(reduced_coeff, exp, sign);
789+
*this = decimal128_t(reduced_coeff, exp, is_negative);
790790
}
791791
else if (digit_delta < 0 && coeff_digits - digit_delta <= detail::precision_v<decimal128_t>)
792792
{
793793
const auto offset {detail::precision_v<decimal128_t> - coeff_digits};
794794
exp -= offset;
795795
reduced_coeff *= detail::pow10(static_cast<significand_type>(offset));
796-
*this = decimal128_t(reduced_coeff, exp, sign);
796+
*this = decimal128_t(reduced_coeff, exp, is_negative);
797797
}
798798
else
799799
{
800800
bits_ = exp < 0 ? zero : detail::d128_inf_mask;
801-
bits_.high |= sign ? detail::d128_sign_mask : UINT64_C(0);
801+
bits_.high |= is_negative ? detail::d128_sign_mask : UINT64_C(0);
802802
}
803803
}
804804
}

include/boost/decimal/decimal32_t.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
288288
#else
289289
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true>
290290
#endif
291-
constexpr decimal32_t(T1 coeff, T2 exp, bool sign = false) noexcept;
291+
constexpr decimal32_t(T1 coeff, T2 exp, bool is_negative = false) noexcept;
292292

293293
#ifdef BOOST_DECIMAL_HAS_CONCEPTS
294294
template <BOOST_DECIMAL_SIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
@@ -642,20 +642,20 @@ template <BOOST_DECIMAL_UNSIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
642642
#else
643643
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool>>
644644
#endif
645-
constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool sign) noexcept // NOLINT(readability-function-cognitive-complexity,misc-no-recursion)
645+
constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool is_negative) noexcept // NOLINT(readability-function-cognitive-complexity,misc-no-recursion)
646646
{
647647
static_assert(detail::is_integral_v<T1>, "Coefficient must be an integer");
648648
static_assert(detail::is_integral_v<T2>, "Exponent must be an integer");
649649

650-
bits_ = sign ? detail::d32_sign_mask : UINT32_C(0);
650+
bits_ = is_negative ? detail::d32_sign_mask : UINT32_C(0);
651651

652652
// If the coeff is not in range, make it so
653653
// Only count the number of digits if we absolutely have to
654654
int coeff_digits {-1};
655655
auto biased_exp {static_cast<int>(exp + detail::bias)};
656656
if (coeff > detail::d32_max_significand_value || biased_exp < 0)
657657
{
658-
coeff_digits = detail::coefficient_rounding<decimal32_t>(coeff, exp, biased_exp, sign, detail::num_digits(coeff));
658+
coeff_digits = detail::coefficient_rounding<decimal32_t>(coeff, exp, biased_exp, is_negative, detail::num_digits(coeff));
659659
}
660660

661661
auto reduced_coeff {static_cast<significand_type>(coeff)};
@@ -708,21 +708,21 @@ constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool sign) noexcept // NOLI
708708
{
709709
exp -= digit_delta;
710710
reduced_coeff *= detail::pow10(static_cast<significand_type>(digit_delta));
711-
*this = decimal32_t(reduced_coeff, exp, sign);
711+
*this = decimal32_t(reduced_coeff, exp, is_negative);
712712
}
713713
else if (digit_delta < 0 && coeff_digits - digit_delta <= detail::precision)
714714
{
715715
// We can expand the coefficient to use the maximum number of digits
716716
const auto offset {detail::precision - coeff_digits};
717717
exp -= offset;
718718
reduced_coeff *= detail::pow10(static_cast<significand_type>(offset));
719-
*this = decimal32_t(reduced_coeff, exp, sign);
719+
*this = decimal32_t(reduced_coeff, exp, is_negative);
720720
}
721721
else
722722
{
723723
// Reset the value and make sure to preserve the sign of 0/inf
724724
bits_ = exp < 0 ? UINT32_C(0) : detail::d32_inf_mask;
725-
bits_ |= sign ? detail::d32_sign_mask : UINT32_C(0);
725+
bits_ |= is_negative ? detail::d32_sign_mask : UINT32_C(0);
726726
}
727727
}
728728
}

include/boost/decimal/decimal64_t.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
325325
#else
326326
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true>
327327
#endif
328-
constexpr decimal64_t(T1 coeff, T2 exp, bool sign = false) noexcept;
328+
constexpr decimal64_t(T1 coeff, T2 exp, bool is_negative = false) noexcept;
329329

330330
#ifdef BOOST_DECIMAL_HAS_CONCEPTS
331331
template <BOOST_DECIMAL_SIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
@@ -640,16 +640,16 @@ template <BOOST_DECIMAL_UNSIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
640640
#else
641641
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool>>
642642
#endif
643-
constexpr decimal64_t::decimal64_t(T1 coeff, T2 exp, bool sign) noexcept
643+
constexpr decimal64_t::decimal64_t(T1 coeff, T2 exp, bool is_negative) noexcept
644644
{
645-
bits_ = sign ? detail::d64_sign_mask : UINT64_C(0);
645+
bits_ = is_negative ? detail::d64_sign_mask : UINT64_C(0);
646646

647647
// If the coeff is not in range, make it so
648648
int coeff_digits {-1};
649649
auto biased_exp {static_cast<int>(exp) + detail::bias_v<decimal64_t>};
650650
if (coeff > detail::d64_max_significand_value || biased_exp < 0)
651651
{
652-
coeff_digits = detail::coefficient_rounding<decimal64_t>(coeff, exp, biased_exp, sign, detail::num_digits(coeff));
652+
coeff_digits = detail::coefficient_rounding<decimal64_t>(coeff, exp, biased_exp, is_negative, detail::num_digits(coeff));
653653
}
654654

655655
auto reduced_coeff {static_cast<significand_type>(coeff)};
@@ -702,20 +702,20 @@ constexpr decimal64_t::decimal64_t(T1 coeff, T2 exp, bool sign) noexcept
702702
{
703703
exp -= digit_delta;
704704
reduced_coeff *= detail::pow10(static_cast<significand_type>(digit_delta));
705-
*this = decimal64_t(reduced_coeff, exp, sign);
705+
*this = decimal64_t(reduced_coeff, exp, is_negative);
706706
}
707707
else if (digit_delta < 0 && coeff_digits - digit_delta <= detail::precision_v<decimal64_t>)
708708
{
709709
const auto offset {detail::precision_v<decimal64_t> - coeff_digits};
710710
exp -= offset;
711711
reduced_coeff *= detail::pow10(static_cast<significand_type>(offset));
712-
*this = decimal64_t(reduced_coeff, exp, sign);
712+
*this = decimal64_t(reduced_coeff, exp, is_negative);
713713
}
714714
else
715715
{
716716
// Reset the value and make sure to preserve the sign of 0/inf
717717
bits_ = exp < 0 ? UINT64_C(0) : detail::d64_inf_mask;
718-
bits_ |= sign ? detail::d64_sign_mask : UINT64_C(0);
718+
bits_ |= is_negative ? detail::d64_sign_mask : UINT64_C(0);
719719
}
720720
}
721721
}

include/boost/decimal/decimal_fast128_t.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
197197
#else
198198
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true>
199199
#endif
200-
constexpr decimal_fast128_t(T1 coeff, T2 exp, bool sign = false) noexcept;
200+
constexpr decimal_fast128_t(T1 coeff, T2 exp, bool is_negative = false) noexcept;
201201

202202
#ifdef BOOST_DECIMAL_HAS_CONCEPTS
203203
template <BOOST_DECIMAL_SIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
@@ -471,17 +471,17 @@ template <BOOST_DECIMAL_UNSIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
471471
#else
472472
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool>>
473473
#endif
474-
constexpr decimal_fast128_t::decimal_fast128_t(T1 coeff, T2 exp, bool sign) noexcept
474+
constexpr decimal_fast128_t::decimal_fast128_t(T1 coeff, T2 exp, bool is_negative) noexcept
475475
{
476476
using minimum_coefficient_size = std::conditional_t<(sizeof(T1) > sizeof(significand_type)), T1, significand_type>;
477477

478478
minimum_coefficient_size min_coeff {coeff};
479479

480-
sign_ = sign;
480+
sign_ = is_negative;
481481

482482
// Normalize the significand in the constructor, so we don't have
483483
// to calculate the number of digits for operations
484-
detail::normalize<decimal_fast128_t>(min_coeff, exp, sign);
484+
detail::normalize<decimal_fast128_t>(min_coeff, exp, is_negative);
485485

486486
significand_ = static_cast<significand_type>(min_coeff);
487487

include/boost/decimal/decimal_fast32_t.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
193193
constexpr decimal_fast32_t() noexcept = default;
194194

195195
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true>
196-
constexpr decimal_fast32_t(T1 coeff, T2 exp, bool sign = false) noexcept;
196+
constexpr decimal_fast32_t(T1 coeff, T2 exp, bool is_negative = false) noexcept;
197197

198198
template <typename T1, typename T2, std::enable_if_t<!detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true>
199199
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}"); }
@@ -461,16 +461,16 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
461461
};
462462

463463
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool>>
464-
constexpr decimal_fast32_t::decimal_fast32_t(T1 coeff, T2 exp, bool sign) noexcept
464+
constexpr decimal_fast32_t::decimal_fast32_t(T1 coeff, T2 exp, bool is_negative) noexcept
465465
{
466466
using minimum_coefficient_size = std::conditional_t<(sizeof(T1) > sizeof(significand_type)), T1, significand_type>;
467467

468468
minimum_coefficient_size min_coeff {coeff};
469469

470-
sign_ = sign;
470+
sign_ = is_negative;
471471

472472
// Normalize in the constructor, so we never have to worry about it again
473-
detail::normalize<decimal_fast32_t>(min_coeff, exp, sign);
473+
detail::normalize<decimal_fast32_t>(min_coeff, exp, is_negative);
474474

475475
significand_ = static_cast<significand_type>(min_coeff);
476476

include/boost/decimal/decimal_fast64_t.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
204204
#else
205205
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool> = true>
206206
#endif
207-
constexpr decimal_fast64_t(T1 coeff, T2 exp, bool sign = false) noexcept;
207+
constexpr decimal_fast64_t(T1 coeff, T2 exp, bool is_negative = false) noexcept;
208208

209209
#ifdef BOOST_DECIMAL_HAS_CONCEPTS
210210
template <BOOST_DECIMAL_SIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
@@ -465,16 +465,16 @@ template <BOOST_DECIMAL_UNSIGNED_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL T2>
465465
#else
466466
template <typename T1, typename T2, std::enable_if_t<detail::is_unsigned_v<T1> && detail::is_integral_v<T2>, bool>>
467467
#endif
468-
constexpr decimal_fast64_t::decimal_fast64_t(T1 coeff, T2 exp, bool sign) noexcept
468+
constexpr decimal_fast64_t::decimal_fast64_t(T1 coeff, T2 exp, bool is_negative) noexcept
469469
{
470470
using minimum_coefficient_size = std::conditional_t<(sizeof(T1) > sizeof(significand_type)), T1, significand_type>;
471471

472472
minimum_coefficient_size min_coeff {coeff};
473473

474-
sign_ = sign;
474+
sign_ = is_negative;
475475

476476
// Normalize the value, so we don't have to worry about it with operations
477-
detail::normalize<decimal_fast64_t>(min_coeff, exp, sign);
477+
detail::normalize<decimal_fast64_t>(min_coeff, exp, is_negative);
478478

479479
significand_ = static_cast<significand_type>(min_coeff);
480480

0 commit comments

Comments
 (0)