susumu.yata
null+****@clear*****
Mon Jan 5 16:50:35 JST 2015
susumu.yata 2015-01-05 16:50:35 +0900 (Mon, 05 Jan 2015) New Revision: c52ba4a466e2af5dc230551214e44159082ec7a5 https://github.com/groonga/grnxx/commit/c52ba4a466e2af5dc230551214e44159082ec7a5 Message: Add Float::hash(). (#132) Modified files: include/grnxx/data_types/scalar/float.hpp Modified: include/grnxx/data_types/scalar/float.hpp (+12 -0) =================================================================== --- include/grnxx/data_types/scalar/float.hpp 2015-01-05 16:46:03 +0900 (7b2aeb1) +++ include/grnxx/data_types/scalar/float.hpp 2015-01-05 16:50:35 +0900 (d86fb1b) @@ -45,6 +45,18 @@ class Float { return std::isnan(raw_); } + uint64_t hash() const { + double normalized_raw = (raw_ != 0.0) ? raw_ : 0.0; + uint64_t x; + std::memcpy(&x, &normalized_raw, sizeof(x)); + x ^= x >> 33; + x *= uint64_t(0xFF51AFD7ED558CCDULL); + x ^= x >> 33; + x *= uint64_t(0xC4CEB9FE1A85EC53ULL); + x ^= x >> 33; + return x; + } + // -- Unary operators -- constexpr Float operator+() const { -------------- next part -------------- HTML����������������������������...Download