This is how it is currently implemented in stdc++:
162
164 struct hash<float> :
public __hash_base<size_t, float>
167 operator()(
float __val)
const noexcept
170 return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
And _Hash_impl just does a "bitwise-like" hashing - it uses all the bits for hashing:
126 struct _Hash_impl
129 hash(
const void* __ptr,
size_t __clength,
130 size_t __seed = static_cast<size_t>(0xc70f6907UL))
131 {
return _Hash_bytes(__ptr, __clength, __seed); }
133 template<
typename _Tp>
135 hash(
const _Tp& __val)
136 {
return hash(&__val,
sizeof(__val)); }
It is not in accordance with what Mr. Knuth told us at the university :D, since there is always an error - and in practice, we should always take it into account: fabs(float1 - float2) <= error1 + error2.