Skip to content

Commit

Permalink
Merge pull request #155 from BoostGSoC21/further_specfun
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos authored Dec 21, 2024
2 parents 68b889a + ec8679d commit 9432444
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions include/boost/multiprecision/cpp_double_fp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,11 @@ bool cpp_double_fp_backend<FloatingPointType>::rd_string(const char* pstr)

if (is_definitely_inf)
{
const bool b_neg { f_dec.isneg() };

static_cast<void>(operator=(local_double_fp_type::my_value_inf()));

if (b_neg) { negate(); }
}
else
{
Expand Down Expand Up @@ -1394,9 +1398,9 @@ constexpr void eval_sqrt(cpp_double_fp_backend<FloatingPointType>& result, const
using double_float_type = cpp_double_fp_backend<FloatingPointType>;
using local_float_type = typename double_float_type::float_type;

const auto fpc = eval_fpclassify(o);
const int fpc { eval_fpclassify(o) };

const auto isneg_o = o.isneg();
const bool isneg_o { o.isneg() };

if ((fpc != FP_NORMAL) || isneg_o)
{
Expand All @@ -1405,14 +1409,14 @@ constexpr void eval_sqrt(cpp_double_fp_backend<FloatingPointType>& result, const
result = double_float_type(0);
return;
}
else if (fpc == FP_NAN)
else if ((fpc == FP_NAN) || isneg_o)
{
result = double_float_type::my_value_nan();
return;
}
else if ((fpc == FP_INFINITE) || isneg_o)
else if (fpc == FP_INFINITE)
{
result = double_float_type::my_value_nan();
result = double_float_type::my_value_inf();
return;
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/test_arithmetic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,11 @@ void test_float_funcs(const std::integral_constant<bool, true>&)
a = 4;
a = sqrt(a);
BOOST_CHECK_CLOSE_FRACTION(a, 2, tol);
BOOST_IF_CONSTEXPR(std::numeric_limits<Real>::is_specialized && std::numeric_limits<Real>::has_infinity)
{
a = std::numeric_limits<Real>::infinity();
BOOST_CHECK((boost::math::isinf)(a));
}
a = 3;
a = exp(a);
BOOST_CHECK_CLOSE_FRACTION(a, Real(exp(Real(3))), tol);
Expand Down

0 comments on commit 9432444

Please sign in to comment.