@@ -232,6 +232,9 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
232232 template <typename Decimal>
233233 friend constexpr Decimal detail::check_non_finite (Decimal lhs, Decimal rhs) noexcept ;
234234
235+ template <typename Decimal>
236+ friend constexpr Decimal detail::check_non_finite (Decimal x) noexcept ;
237+
235238public:
236239 // 3.2.4.1 construct/copy/destroy
237240 constexpr decimal128_t () noexcept = default;
@@ -1709,7 +1712,7 @@ constexpr auto operator+(const decimal128_t lhs, const Integer rhs) noexcept
17091712 #ifndef BOOST_DECIMAL_FAST_MATH
17101713 if (not_finite (lhs))
17111714 {
1712- return lhs;
1715+ return detail::check_non_finite ( lhs) ;
17131716 }
17141717 #endif
17151718
@@ -1773,7 +1776,7 @@ constexpr auto operator-(const decimal128_t lhs, const Integer rhs) noexcept
17731776 #ifndef BOOST_DECIMAL_FAST_MATH
17741777 if (not_finite (lhs))
17751778 {
1776- return lhs;
1779+ return detail::check_non_finite ( lhs) ;
17771780 }
17781781 #endif
17791782
@@ -1802,7 +1805,7 @@ constexpr auto operator-(const Integer lhs, const decimal128_t rhs) noexcept
18021805 #ifndef BOOST_DECIMAL_FAST_MATH
18031806 if (not_finite (rhs))
18041807 {
1805- return rhs;
1808+ return detail::check_non_finite ( rhs) ;
18061809 }
18071810 #endif
18081811
@@ -1853,7 +1856,7 @@ constexpr auto operator*(const decimal128_t lhs, const Integer rhs) noexcept
18531856 #ifndef BOOST_DECIMAL_FAST_MATH
18541857 if (not_finite (lhs))
18551858 {
1856- return lhs;
1859+ return detail::check_non_finite ( lhs) ;
18571860 }
18581861 #endif
18591862
@@ -1897,8 +1900,7 @@ constexpr auto operator/(const decimal128_t lhs, const Integer rhs) noexcept
18971900 #ifndef BOOST_DECIMAL_FAST_MATH
18981901 // Check pre-conditions
18991902 constexpr decimal128_t zero {0 , 0 };
1900- constexpr decimal128_t nan {boost::decimal::from_bits (boost::decimal::detail::d128_snan_mask)};
1901- constexpr decimal128_t inf {boost::decimal::from_bits (boost::decimal::detail::d128_inf_mask)};
1903+ constexpr decimal128_t inf {from_bits (detail::d128_inf_mask)};
19021904
19031905 const bool sign {lhs.isneg () != (rhs < 0 )};
19041906
@@ -1907,9 +1909,9 @@ constexpr auto operator/(const decimal128_t lhs, const Integer rhs) noexcept
19071909 switch (lhs_fp)
19081910 {
19091911 case FP_NAN:
1910- return nan ;
1912+ return issignaling (lhs) ? nan_conversion (lhs) : lhs ;
19111913 case FP_INFINITE:
1912- return inf ;
1914+ return lhs ;
19131915 case FP_ZERO:
19141916 return sign ? -zero : zero;
19151917 default :
@@ -1940,20 +1942,16 @@ constexpr auto operator/(const Integer lhs, const decimal128_t rhs) noexcept
19401942 #ifndef BOOST_DECIMAL_FAST_MATH
19411943 // Check pre-conditions
19421944 constexpr decimal128_t zero {0 , 0 };
1943- constexpr decimal128_t inf {boost::decimal::from_bits (boost::decimal::detail::d128_inf_mask)};
1944- constexpr decimal128_t nan {boost::decimal::from_bits (boost::decimal::detail::d128_snan_mask)};
1945+ constexpr decimal128_t inf {from_bits (detail::d128_inf_mask)};
19451946
19461947 const bool sign {(lhs < 0 ) != rhs.isneg ()};
19471948
19481949 const auto rhs_fp {fpclassify (rhs)};
19491950
1950- if (rhs_fp == FP_NAN)
1951- {
1952- return nan;
1953- }
1954-
19551951 switch (rhs_fp)
19561952 {
1953+ case FP_NAN:
1954+ return issignaling (rhs) ? nan_conversion (rhs) : rhs;
19571955 case FP_INFINITE:
19581956 return sign ? -zero : zero;
19591957 case FP_ZERO:
0 commit comments