Skip to content

Commit

Permalink
Reduce d64_fast isnan to a single comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Jan 23, 2025
1 parent 633b11d commit 64797e7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions include/boost/decimal/decimal64_fast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace decimal {

namespace detail {

BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_inf = std::numeric_limits<std::uint_fast64_t>::max();
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_qnan = std::numeric_limits<std::uint_fast64_t>::max() - 1;
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_snan = std::numeric_limits<std::uint_fast64_t>::max() - 2;
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_inf = std::numeric_limits<std::uint_fast64_t>::max() - 3;
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_qnan = std::numeric_limits<std::uint_fast64_t>::max() - 2;
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_snan = std::numeric_limits<std::uint_fast64_t>::max() - 1;

struct decimal64_fast_components
{
Expand Down Expand Up @@ -479,8 +479,7 @@ constexpr auto isinf(decimal64_fast val) noexcept -> bool
constexpr auto isnan(decimal64_fast val) noexcept -> bool
{
#ifndef BOOST_DECIMAL_FAST_MATH
return val.significand_ == detail::d64_fast_qnan ||
val.significand_ == detail::d64_fast_snan;
return val.significand_ >= detail::d64_fast_qnan;
#else
static_cast<void>(val);
return false;
Expand Down Expand Up @@ -513,12 +512,12 @@ constexpr auto isnormal(decimal64_fast val) noexcept -> bool

constexpr auto isfinite(decimal64_fast val) noexcept -> bool
{
return val.significand_ < detail::d64_fast_snan;
return val.significand_ < detail::d64_fast_inf;
}

constexpr auto not_finite(decimal64_fast val) noexcept -> bool
{
return val.significand_ >= detail::d64_fast_snan;
return val.significand_ >= detail::d64_fast_inf;
}

constexpr auto operator==(decimal64_fast lhs, decimal64_fast rhs) noexcept -> bool
Expand Down

0 comments on commit 64797e7

Please sign in to comment.