Skip to content

Commit 3a856fc

Browse files
committed
Auto normalize with frexp10
1 parent 84b94fe commit 3a856fc

File tree

1 file changed

+3
-12
lines changed
  • include/boost/decimal/detail/cmath

1 file changed

+3
-12
lines changed

include/boost/decimal/detail/cmath/next.hpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,14 @@ constexpr auto nextafter_impl(const DecimalType val, const bool direction) noexc
4444
return min_val;
4545
}
4646

47-
const auto components {val.to_components()};
48-
auto sig {components.sig};
49-
auto exp {components.exp};
50-
const auto removed_zeros {remove_trailing_zeros(sig)};
51-
const auto sig_dig {num_digits(sig)};
47+
int exp {};
48+
auto sig {frexp10(val, &exp)};
49+
const auto removed_zeros(remove_trailing_zeros(sig));
5250

5351
// Our two boundaries
5452
const bool is_pow_10 {removed_zeros.trimmed_number == 1U};
5553
const bool is_max_sig {sig == detail::max_significand_v<DecimalType>};
5654

57-
if (sig_dig < detail::precision_v<DecimalType>)
58-
{
59-
const auto offset{detail::precision_v<DecimalType> - sig_dig};
60-
sig *= pow10(static_cast<decltype(sig)>(detail::precision_v<DecimalType> - sig_dig));
61-
exp -= offset;
62-
}
63-
6455
if (direction)
6556
{
6657
// Val < direction = +

0 commit comments

Comments
 (0)