• Advertisement
Sign in to follow this  

Hashing 3 floats

This topic is 4947 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I have a list of float triplets and I need to make some sort of hash value (int) from each triplet. I need an algorithm that produces different hash values even for slightly different floats... Any ideas? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
int value = *((unsigned int *)&the_float);

then hash the value with appropriate hash function

Share this post


Link to post
Share on other sites
I just use a standard CRC function (look up "pkzip CRC").

You could also do something like this though it is probably no faster:
    srand( *(int *)&float1 );
srand( rand() ^ *(int *)&float2 );
srand( rand() ^ *(int *)&float3 );

hash = rand();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement