Skip to content

Commit 0659137

Browse files
committed
Fix mixed nans handling
1 parent 72c5c5a commit 0659137

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/boost/decimal/decimal128_t.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,13 @@ template <typename Integer>
18011801
constexpr auto operator-(const Integer lhs, const decimal128_t rhs) noexcept
18021802
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal128_t)
18031803
{
1804+
#ifndef BOOST_DECIMAL_FAST_MATH
1805+
if (not_finite(rhs))
1806+
{
1807+
return detail::check_non_finite(rhs);
1808+
}
1809+
#endif
1810+
18041811
return -rhs + lhs;
18051812
}
18061813

include/boost/decimal/decimal_fast128_t.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,13 @@ template <typename Integer>
11101110
constexpr auto operator-(const Integer lhs, const decimal_fast128_t& rhs) noexcept
11111111
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal_fast128_t)
11121112
{
1113+
#ifndef BOOST_DECIMAL_FAST_MATH
1114+
if (not_finite(rhs))
1115+
{
1116+
return detail::check_non_finite(rhs);
1117+
}
1118+
#endif
1119+
11131120
return -rhs + lhs;
11141121
}
11151122

0 commit comments

Comments
 (0)