Skip to content

Commit

Permalink
Refactor computation of 80 and 128 bit ldbls
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Oct 7, 2024
1 parent 8274270 commit df650ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ constexpr auto fast_path(const std::int64_t q, const Unsigned_Integer &w, bool n
#endif

template <typename Unsigned_Integer>
constexpr auto compute_float80(std::int64_t q, const Unsigned_Integer &w,
const bool negative, bool &success) noexcept -> long double
constexpr auto compute_float80_128(std::int64_t q, const Unsigned_Integer &w,
const bool negative, bool &success) noexcept -> long double
{
// GLIBC uses 2^-16444 but MPFR uses 2^-16445 as the smallest subnormal value for 80 bit
// 39 is the max number of digits in an uint128_t
Expand Down
3 changes: 1 addition & 2 deletions include/boost/decimal/detail/to_float.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ BOOST_DECIMAL_CXX20_CONSTEXPR auto to_float(Decimal val) noexcept
#if BOOST_DECIMAL_LDBL_BITS == 64
result = static_cast<TargetType>(detail::fast_float::compute_float64(exp, new_sig, val.isneg(), success));
#else
result = static_cast<TargetType>(detail::fast_float::compute_float80(exp, new_sig, val.isneg(), success));
result = static_cast<TargetType>(detail::fast_float::compute_float80_128(exp, new_sig, val.isneg(), success));
#endif
}
// TODO(mborland): Add conversion for __float128 and 128 bit long doubles

if (BOOST_DECIMAL_UNLIKELY(!success))
{
Expand Down

0 comments on commit df650ed

Please sign in to comment.