Hashing 3 floats

Started by
1 comment, last by JohnBolton 19 years, 9 months ago
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
Advertisement
int value = *((unsigned int *)&the_float);

then hash the value with appropriate hash function
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(); 

John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement