Skip to content

Commit 641a302

Browse files
committed
Use single arg check_non_finite for decimal_fast64_t
1 parent f5d6d63 commit 641a302

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

include/boost/decimal/decimal_fast64_t.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
228228
template <typename Decimal>
229229
friend constexpr Decimal detail::check_non_finite(Decimal lhs, Decimal rhs) noexcept;
230230

231+
template <typename Decimal>
232+
friend constexpr Decimal detail::check_non_finite(Decimal x) noexcept;
233+
231234
public:
232235
constexpr decimal_fast64_t() noexcept = default;
233236

@@ -1132,7 +1135,7 @@ constexpr auto operator+(const decimal_fast64_t lhs, const Integer rhs) noexcept
11321135
#ifndef BOOST_DECIMAL_FAST_MATH
11331136
if (not_finite(lhs))
11341137
{
1135-
return lhs;
1138+
return detail::check_non_finite(lhs);
11361139
}
11371140
#endif
11381141

@@ -1184,7 +1187,7 @@ constexpr auto operator-(const decimal_fast64_t lhs, const Integer rhs) noexcept
11841187
#ifndef BOOST_DECIMAL_FAST_MATH
11851188
if (not_finite(lhs))
11861189
{
1187-
return lhs;
1190+
return detail::check_non_finite(lhs);
11881191
}
11891192
#endif
11901193

@@ -1210,7 +1213,7 @@ constexpr auto operator-(const Integer lhs, const decimal_fast64_t rhs) noexcept
12101213
#ifndef BOOST_DECIMAL_FAST_MATH
12111214
if (not_finite(rhs))
12121215
{
1213-
return rhs;
1216+
return detail::check_non_finite(rhs);
12141217
}
12151218
#endif
12161219

@@ -1253,7 +1256,7 @@ constexpr auto operator*(const decimal_fast64_t lhs, const Integer rhs) noexcept
12531256
#ifndef BOOST_DECIMAL_FAST_MATH
12541257
if (not_finite(lhs))
12551258
{
1256-
return lhs;
1259+
return detail::check_non_finite(lhs);
12571260
}
12581261
#endif
12591262

@@ -1406,17 +1409,16 @@ constexpr auto operator/(const decimal_fast64_t lhs, const Integer rhs) noexcept
14061409
#ifndef BOOST_DECIMAL_FAST_MATH
14071410
// Check pre-conditions
14081411
constexpr decimal_fast64_t zero {0, 0};
1409-
constexpr decimal_fast64_t nan {boost::decimal::direct_init_d64(boost::decimal::detail::d64_fast_snan, 0, false)};
1410-
constexpr decimal_fast64_t inf {boost::decimal::direct_init_d64(boost::decimal::detail::d64_fast_inf, 0, false)};
1412+
constexpr decimal_fast64_t inf {direct_init_d64(detail::d64_fast_inf, 0, false)};
14111413

14121414
const auto lhs_fp {fpclassify(lhs)};
14131415

14141416
switch (lhs_fp)
14151417
{
14161418
case FP_NAN:
1417-
return nan;
1419+
return issignaling(lhs) ? nan_conversion(lhs) : lhs;;
14181420
case FP_INFINITE:
1419-
return inf;
1421+
return lhs;
14201422
case FP_ZERO:
14211423
return sign ? -zero : zero;
14221424
default:
@@ -1450,15 +1452,14 @@ constexpr auto operator/(const Integer lhs, const decimal_fast64_t rhs) noexcept
14501452
#ifndef BOOST_DECIMAL_FAST_MATH
14511453
// Check pre-conditions
14521454
constexpr decimal_fast64_t zero {0, 0};
1453-
constexpr decimal_fast64_t nan {boost::decimal::direct_init_d64(boost::decimal::detail::d64_fast_snan, 0, false)};
1454-
constexpr decimal_fast64_t inf {boost::decimal::direct_init_d64(boost::decimal::detail::d64_fast_inf, 0, false)};
1455+
constexpr decimal_fast64_t inf {direct_init_d64(detail::d64_fast_inf, 0, false)};
14551456

14561457
const auto rhs_fp {fpclassify(rhs)};
14571458

14581459
switch (rhs_fp)
14591460
{
14601461
case FP_NAN:
1461-
return nan;
1462+
return issignaling(rhs) ? nan_conversion(rhs) : rhs;
14621463
case FP_INFINITE:
14631464
return sign ? -zero : zero;
14641465
case FP_ZERO:

test/test_nan_conversions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ int main()
251251
generate_mixed_tests<decimal128_t>();
252252

253253
generate_mixed_tests<decimal_fast32_t>();
254-
//generate_mixed_tests<decimal_fast64_t>();
254+
generate_mixed_tests<decimal_fast64_t>();
255255
//generate_mixed_tests<decimal_fast128_t>();
256256

257257
return boost::report_errors();

0 commit comments

Comments
 (0)