Skip to content

Commit 0b474bf

Browse files
committed
Handle unclear code from local metal benching
1 parent 24b9406 commit 0b474bf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

include/boost/decimal/decimal32_fast.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,12 +1000,16 @@ constexpr auto div_impl(decimal_fast32_t lhs, decimal_fast32_t rhs, decimal_fast
10001000
<< "\nexp rhs: " << exp_rhs << std::endl;
10011001
#endif
10021002

1003+
using local_signed_exponent_type = std::common_type_t<std::int_fast32_t, int>;
1004+
1005+
static_assert(sizeof(local_signed_exponent_type) >= 4, "Error in local exponent type definition");
1006+
10031007
// We promote to uint64 since the significands are currently 32-bits
10041008
// By appending enough zeros to the LHS we end up finding what we need anyway
10051009
constexpr auto ten_pow_precision {detail::pow10(static_cast<std::uint_fast64_t>(detail::precision_v<decimal32_t>))};
10061010
const auto big_sig_lhs {static_cast<std::uint_fast64_t>(lhs.significand_) * ten_pow_precision};
10071011
auto res_sig {big_sig_lhs / static_cast<std::uint_fast64_t>(rhs.significand_)};
1008-
auto res_exp {lhs.exponent_ - rhs.exponent_ + 94};
1012+
local_signed_exponent_type res_exp {static_cast<local_signed_exponent_type>(lhs.exponent_) - static_cast<local_signed_exponent_type>(rhs.exponent_) + 94};
10091013
const auto isneg {lhs.sign_ != rhs.sign_};
10101014

10111015
// If we have 8 figures round it down to 7

include/boost/decimal/detail/buffer_sizing.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ namespace detail {
2323
#endif
2424

2525
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE Dec>
26-
constexpr int get_real_precision(int precision = -1) noexcept
26+
constexpr int get_real_precision(int my_precision = -1) noexcept
2727
{
2828
// If the user did not specify a precision than we use the maximum representable amount
2929
// and remove trailing zeros at the end
30-
return precision == -1 ? std::numeric_limits<Dec>::max_digits10 : precision;
30+
return my_precision == -1 ? std::numeric_limits<Dec>::max_digits10 : precision;
3131
}
3232

3333
// We don't need to use the full digit counting since the range of the exponents is well defined

0 commit comments

Comments
 (0)