diff --git a/include/boost/multiprecision/cpp_int/import_export.hpp b/include/boost/multiprecision/cpp_int/import_export.hpp index 3ba3442d..7bd843fb 100644 --- a/include/boost/multiprecision/cpp_int/import_export.hpp +++ b/include/boost/multiprecision/cpp_int/import_export.hpp @@ -199,8 +199,8 @@ namespace boost { template inline boost::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned count, const mpl::true_&) { - boost::uintmax_t result = *val.limbs(); - boost::uintmax_t mask = count == std::numeric_limits::digits ? ~static_cast(0) : (static_cast(1u) << count) - 1; + typename Backend::local_limb_type result = *val.limbs(); + typename Backend::local_limb_type mask = count >= std::numeric_limits::digits ? ~static_cast(0) : (static_cast(1u) << count) - 1; return (result >> location) & mask; }