Skip to content

Commit dff8649

Browse files
committed
Fix handling of denorms
1 parent 07ec53a commit dff8649

File tree

1 file changed

+7
-0
lines changed
  • include/boost/decimal/detail/cmath

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ constexpr auto nextafter_impl(const DecimalType val, const bool direction) noexc
5252
const bool is_pow_10 {removed_zeros.trimmed_number == 1U};
5353
const bool is_max_sig {sig == detail::max_significand_v<DecimalType>};
5454

55+
if (!isnormal(val))
56+
{
57+
// Not to make sure that denorms aren't normalized
58+
sig = removed_zeros.trimmed_number;
59+
exp += removed_zeros.number_of_removed_zeros;
60+
}
61+
5562
if (direction)
5663
{
5764
// Val < direction = +

0 commit comments

Comments
 (0)