diff --git a/include/boost/charconv/detail/compute_float80.hpp b/include/boost/charconv/detail/compute_float80.hpp index d087206..6c67ad8 100644 --- a/include/boost/charconv/detail/compute_float80.hpp +++ b/include/boost/charconv/detail/compute_float80.hpp @@ -170,19 +170,20 @@ inline __float128 pow2top<__float128>(std::int64_t p) noexcept #endif template -inline uint128 mask_mantissa(uint128 z) noexcept; +inline uint128 mask_mantissa(uint256 z) noexcept; #if BOOST_CHARCONV_LDBL_BITS == 80 template -inline uint128 mask_mantissa(uint128 z) noexcept +inline uint128 mask_mantissa(uint256 z) noexcept { - return static_cast(static_cast(z)); + static constexpr uint128 mask {0x1FFFFFFFFFFFF, UINT64_MAX}; + return (z >> 113) & mask; } #elif BOOST_CHARCONV_LDBL_BITS == 128 template -inline uint128 mask_mantissa(uint128 z) noexcept +inline uint128 mask_mantissa(uint256 z) noexcept { static constexpr uint128 mask {0x1FFFFFFFFFFFF, UINT64_MAX}; return (z >> 113) & mask; @@ -192,7 +193,7 @@ inline uint128 mask_mantissa(uint128 z) noexcept #ifdef BOOST_CHARCONV_HAS_FLOAT128 template <> -inline uint128 mask_mantissa<__float128>(uint128 z) noexcept +inline uint128 mask_mantissa<__float128>(uint256 z) noexcept { static constexpr uint128 mask {0x1FFFFFFFFFFFF, UINT64_MAX}; return (z >> 113) & mask; diff --git a/include/boost/charconv/detail/emulated256.hpp b/include/boost/charconv/detail/emulated256.hpp index 625c5e6..50bfbe8 100644 --- a/include/boost/charconv/detail/emulated256.hpp +++ b/include/boost/charconv/detail/emulated256.hpp @@ -45,6 +45,9 @@ struct uint256 return *this; } + inline friend uint256 operator&(uint256 lhs, uint256 rhs) noexcept; + inline friend uint256 operator&(uint256 lhs, uint128 rhs) noexcept; + inline friend bool operator==(uint256 lhs, uint256 rhs) noexcept; inline friend bool operator==(uint256 lhs, std::uint64_t rhs) noexcept; @@ -101,6 +104,16 @@ uint256 operator|(uint256 lhs, uint256 rhs) noexcept return {lhs.high | rhs.high, lhs.low | rhs.low}; } +uint256 operator&(uint256 lhs, uint256 rhs) noexcept +{ + return {lhs.high & rhs.high, lhs.low & rhs.low}; +} + +uint256 operator&(uint256 lhs, uint128 rhs) noexcept +{ + return {lhs.high, lhs.low & rhs.low}; +} + bool operator==(uint256 lhs, uint256 rhs) noexcept { return lhs.high == rhs.high && lhs.low == rhs.low;