Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/boost/decimal/decimal128_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,10 +1052,14 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal128_t::decimal128_t(const Float val) noexce
{
*this = from_bits(detail::d128_nan_mask);
}
else if (val == std::numeric_limits<Float>::infinity() || val == -std::numeric_limits<Float>::infinity())
else if (val == std::numeric_limits<Float>::infinity())
{
*this = from_bits(detail::d128_inf_mask);
}
else if (val == -std::numeric_limits<Float>::infinity())
{
*this = -from_bits(detail::d128_inf_mask);
}
else
#endif
{
Expand Down
6 changes: 5 additions & 1 deletion include/boost/decimal/decimal32_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1801,10 +1801,14 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal32_t::decimal32_t(const Float val) noexcept
{
*this = boost::decimal::from_bits(boost::decimal::detail::d32_nan_mask);
}
else if (val == std::numeric_limits<Float>::infinity() || val == -std::numeric_limits<Float>::infinity())
else if (val == std::numeric_limits<Float>::infinity())
{
*this = boost::decimal::from_bits(boost::decimal::detail::d32_inf_mask);
}
else if (val == -std::numeric_limits<Float>::infinity())
{
*this = -boost::decimal::from_bits(boost::decimal::detail::d32_inf_mask);
}
else
#endif
{
Expand Down
6 changes: 5 additions & 1 deletion include/boost/decimal/decimal64_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,10 +1006,14 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal64_t::decimal64_t(const Float val) noexcept
{
*this = from_bits(detail::d64_nan_mask);
}
else if (val == std::numeric_limits<Float>::infinity() || val == -std::numeric_limits<Float>::infinity())
else if (val == std::numeric_limits<Float>::infinity())
{
*this = from_bits(detail::d64_inf_mask);
}
else if (val == -std::numeric_limits<Float>::infinity())
{
*this = -from_bits(detail::d64_inf_mask);
}
else
#endif
{
Expand Down
7 changes: 6 additions & 1 deletion include/boost/decimal/decimal_fast128_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,15 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t::decimal_fast128_t(const Float v
{
significand_ = detail::d128_fast_qnan;
}
else if (val == std::numeric_limits<Float>::infinity() || val == -std::numeric_limits<Float>::infinity())
else if (val == std::numeric_limits<Float>::infinity())
{
significand_ = detail::d128_fast_inf;
}
else if (val == -std::numeric_limits<Float>::infinity())
{
significand_ = detail::d128_fast_inf;
sign_ = true;
}
else
#endif
{
Expand Down
7 changes: 6 additions & 1 deletion include/boost/decimal/decimal_fast32_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,15 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t::decimal_fast32_t(const Float val
{
significand_ = detail::d32_fast_qnan;
}
else if (val == std::numeric_limits<Float>::infinity() || val == -std::numeric_limits<Float>::infinity())
else if (val == std::numeric_limits<Float>::infinity())
{
significand_ = detail::d32_fast_inf;
}
else if (val == -std::numeric_limits<Float>::infinity())
{
significand_ = detail::d32_fast_inf;
sign_ = true;
}
else
#endif
{
Expand Down
7 changes: 6 additions & 1 deletion include/boost/decimal/decimal_fast64_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,15 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast64_t::decimal_fast64_t(const Float val
{
significand_ = detail::d64_fast_qnan;
}
else if (val == std::numeric_limits<Float>::infinity() || val == -std::numeric_limits<Float>::infinity())
else if (val == std::numeric_limits<Float>::infinity())
{
significand_ = detail::d64_fast_inf;
}
else if (val == -std::numeric_limits<Float>::infinity())
{
significand_ = detail::d64_fast_inf;
sign_ = true;
}
else
#endif
{
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ run github_issue_1361.cpp ;
run github_issue_1378.cpp ;
run github_issue_1383.cpp ;
run github_issue_1384.cpp ;
run github_issue_1398.cpp ;

run link_1.cpp link_2.cpp link_3.cpp ;
run quick.cpp ;
Expand Down
5 changes: 5 additions & 0 deletions test/github_issue_1384.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright 2026 Chris Kormanyos
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// See: https://github.com/boostorg/decimal/issues/1384

#include <boost/core/lightweight_test.hpp>

Expand Down
42 changes: 42 additions & 0 deletions test/github_issue_1398.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2026 Chris Kormanyos
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// See: https://github.com/boostorg/decimal/issues/1398

#include <boost/decimal.hpp>
#include <boost/core/lightweight_test.hpp>
#include <limits>

template <typename T, typename U>
void test_driver()
{
using namespace boost::decimal;

constexpr auto builtin_neg_inf = -std::numeric_limits<T>::infinity();

const auto val = U(builtin_neg_inf);
BOOST_TEST(isinf(val));
BOOST_TEST(val < 0);
}

template <typename T>
void test()
{
using namespace boost::decimal;

test_driver<T, decimal32_t>();
test_driver<T, decimal64_t>();
test_driver<T, decimal128_t>();
test_driver<T, decimal_fast32_t>();
test_driver<T, decimal_fast64_t>();
test_driver<T, decimal_fast128_t>();
}

int main()
{
test<float>();
test<double>();

return boost::report_errors();
}
Loading