diff --git a/include/boost/container_hash/detail/hash_range.hpp b/include/boost/container_hash/detail/hash_range.hpp index 45981c6..84ec97d 100644 --- a/include/boost/container_hash/detail/hash_range.hpp +++ b/include/boost/container_hash/detail/hash_range.hpp @@ -104,7 +104,7 @@ std::size_t>::type boost::uint32_t const k = 0xe35e67b1U; // q * q boost::uint64_t h = mul32( static_cast( seed ) + q, k ); - boost::uint32_t w = static_cast( h ); + boost::uint32_t w = static_cast( h & 0xFFFFFFFF ); h ^= n; @@ -138,9 +138,9 @@ std::size_t>::type } w += q; - h ^= mul32( static_cast( h ) + w, static_cast( h >> 32 ) + w + k ); + h ^= mul32( static_cast( h & 0xFFFFFFFF ) + w, static_cast( h >> 32 ) + w + k ); - return static_cast( h ) ^ static_cast( h >> 32 ); + return static_cast( h & 0xFFFFFFFF ) ^ static_cast( h >> 32 ); } template @@ -157,7 +157,7 @@ std::size_t>::type boost::uint32_t const k = 0xe35e67b1U; // q * q boost::uint64_t h = mul32( static_cast( seed ) + q, k ); - boost::uint32_t w = static_cast( h ); + boost::uint32_t w = static_cast( h & 0xFFFFFFFF ); boost::uint32_t v1 = 0; @@ -211,9 +211,9 @@ std::size_t>::type h ^= mul32( v1 + w, k ); w += q; - h ^= mul32( static_cast( h ) + w, static_cast( h >> 32 ) + w + k ); + h ^= mul32( static_cast( h & 0xFFFFFFFF ) + w, static_cast( h >> 32 ) + w + k ); - return static_cast( h ) ^ static_cast( h >> 32 ); + return static_cast( h & 0xFFFFFFFF ) ^ static_cast( h >> 32 ); } // specialized char[] version, 64 bit diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp index 64987f8..d89938e 100644 --- a/include/boost/container_hash/hash.hpp +++ b/include/boost/container_hash/hash.hpp @@ -118,7 +118,7 @@ namespace boost std::size_t seed = 0; seed = static_cast( v >> 32 ) + hash_detail::hash_mix( seed ); - seed = static_cast( v ) + hash_detail::hash_mix( seed ); + seed = static_cast( v & 0xFFFFFFFF ) + hash_detail::hash_mix( seed ); return seed; }