Answer the question
In order to leave comments, you need to log in
How to hash real numbers?
A simple cast to int is either not suitable, because there is an infernal number of collisions, especially when close double values \u200b\u200bare received as input.
Which hash function is more efficient? memcpy(&doubleValue, &intValue, sizeof(double))
Answer the question
In order to leave comments, you need to log in
The problem with your code is that you only take the first 4 bytes out of 8 in double.
Copy to uint64_t. If you need fewer bits, then you can multiply by a large prime number and then take the xor of the least significant and most significant bits.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question