Skip to content

Commit 3bc93a9

Browse files
committed
Check for unsigned rollover
1 parent caa2791 commit 3bc93a9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/boost/decimal/decimal32_fast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ constexpr decimal32_fast::decimal32_fast(T1 coeff, T2 exp, bool sign) noexcept
382382
auto biased_exp {static_cast<exponent_type>(exp + detail::bias)};
383383

384384
// Decimal32 exponent holds 8 bits
385-
if (biased_exp > detail::max_biased_exp_v<decimal32_fast>)
385+
if (biased_exp > detail::max_biased_exp_v<decimal32_fast> || exp > detail::max_biased_exp_v<decimal32_fast>)
386386
{
387387
significand_ = detail::d32_fast_inf;
388388
}

include/boost/decimal/decimal64_fast.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ constexpr decimal64_fast::decimal64_fast(T1 coeff, T2 exp, bool sign) noexcept
390390
exp = 0;
391391
}
392392

393-
const auto biased_exp {static_cast<std::uint_fast32_t>(exp + detail::bias_v<decimal64>)};
393+
const auto biased_exp {static_cast<exponent_type>(exp + detail::bias_v<decimal64>)};
394394

395-
if (biased_exp > detail::max_biased_exp_v<decimal64>)
395+
if (biased_exp > detail::max_biased_exp_v<decimal64> || exp > detail::max_biased_exp_v<decimal64>)
396396
{
397397
significand_ = detail::d64_fast_inf;
398398
}

0 commit comments

Comments
 (0)