diff --git a/include/fc/uint128.hpp b/include/fc/uint128.hpp index 08c3cc1..cbee51b 100644 --- a/include/fc/uint128.hpp +++ b/include/fc/uint128.hpp @@ -3,6 +3,8 @@ #include #include +#include + #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4244) @@ -74,8 +76,19 @@ namespace fc friend bool operator >= ( const uint128& l, const uint128& r ) { return l == r || l > r; } friend bool operator <= ( const uint128& l, const uint128& r ) { return l == r || l < r; } - uint32_t to_integer()const { return (uint32_t)lo; } - uint64_t to_uint64()const { return lo; } + uint32_t to_integer()const + { + FC_ASSERT( hi == 0 ); + uint32_t lo32 = (uint32_t) lo; + FC_ASSERT( lo == lo32 ); + return lo32; + } + uint64_t to_uint64()const + { + FC_ASSERT( hi == 0 ); + return lo; + } + uint32_t low_32_bits()const { return (uint32_t) lo; } uint64_t low_bits()const { return lo; } uint64_t high_bits()const { return hi; }