diff --git a/include/boost/charconv/detail/ryu/ryu_generic_128.hpp b/include/boost/charconv/detail/ryu/ryu_generic_128.hpp index 0a3910d..c83329f 100644 --- a/include/boost/charconv/detail/ryu/ryu_generic_128.hpp +++ b/include/boost/charconv/detail/ryu/ryu_generic_128.hpp @@ -424,13 +424,13 @@ struct floating_decimal_128 double_to_fd128(double d) noexcept struct floating_decimal_128 long_double_to_fd128(long double d) noexcept { - #ifndef BOOST_CHARCONV_HAS_INT128 + #ifdef BOOST_CHARCONV_HAS_INT128 + unsigned_128_type bits = 0; + std::memcpy(&bits, &d, sizeof(long double)); + #else trivial_uint128 trivial_bits; std::memcpy(&trivial_bits, &d, sizeof(long double)); unsigned_128_type bits {trivial_bits}; - #else - unsigned_128_type bits = 0; - std::memcpy(&bits, &d, sizeof(long double)); #endif #ifdef BOOST_CHARCONV_DEBUG diff --git a/include/boost/charconv/to_chars.hpp b/include/boost/charconv/to_chars.hpp index 169ed1f..4ab52e6 100644 --- a/include/boost/charconv/to_chars.hpp +++ b/include/boost/charconv/to_chars.hpp @@ -854,7 +854,7 @@ BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double val BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value, chars_format fmt = chars_format::general, int precision = -1 ) noexcept; -#if defined(BOOST_CHARCONV_HAS_FLOAT128) && defined(BOOST_CHARCONV_HAS_INT128) +#ifdef BOOST_CHARCONV_HAS_FLOAT128 BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value, chars_format fmt = chars_format::general, int precision = -1 ) noexcept; #endif diff --git a/src/to_chars.cpp b/src/to_chars.cpp index 699c6af..1c4b753 100644 --- a/src/to_chars.cpp +++ b/src/to_chars.cpp @@ -4,6 +4,8 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include +#include #include #include #include @@ -11,7 +13,7 @@ #include #include -#ifdef BOOST_CHARCONV_HAS_INT128 +#if (BOOST_CHARCONV_LDBL_BITS == 80 || BOOST_CHARCONV_LDBL_BITS == 128) # include # include #endif @@ -583,7 +585,7 @@ boost::charconv::to_chars_result boost::charconv::to_chars(char* first, char* la return boost::charconv::detail::to_chars_float_impl(first, last, static_cast(value), fmt, precision); } -#elif (BOOST_CHARCONV_LDBL_BITS == 80 || BOOST_CHARCONV_LDBL_BITS == 128) && defined(BOOST_CHARCONV_HAS_INT128) +#elif (BOOST_CHARCONV_LDBL_BITS == 80 || BOOST_CHARCONV_LDBL_BITS == 128) boost::charconv::to_chars_result boost::charconv::to_chars(char* first, char* last, long double value, boost::charconv::chars_format fmt, int precision) noexcept @@ -711,7 +713,7 @@ boost::charconv::to_chars_result boost::charconv::to_chars( char* first, char* l #endif -#if defined(BOOST_CHARCONV_HAS_FLOAT128) && defined(BOOST_CHARCONV_HAS_INT128) +#ifdef BOOST_CHARCONV_HAS_FLOAT128 boost::charconv::to_chars_result boost::charconv::to_chars(char* first, char* last, __float128 value, boost::charconv::chars_format fmt, int precision) noexcept {