Sign in to follow this  
malyskolacek

Hashing 3 floats

Recommended Posts

malyskolacek    121
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
Guest Anonymous Poster   
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
JohnBolton    1372
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this