Question

From the C++ standard, the hash function std::tr1::hash computes hash values whose range is 64-bits (correct me if i'm wrong). But out of curiosity, are there any mechanisms that generate hash values with range greater than 64-bit. My question may look weird as the entire memory we use is within 64-bit range, but I would like to know how would we compute a hash value of (let's say) size 80-bit?

EDIT : My bad, I assumed 64-bit implementations.

Was it helpful?

Solution

The various hash functions in C++11 (which I suppose corresponds to TR1) compute hash values into a size_t, the size of which depends on the implementation (but will be 32 bits for a 32 bit build, and 64 bits for a 64 bit build). If you need a hash with a larger size, then you'll have to calculate it yourself; you may even have to define a larger integral type to support calculating it. (You can't return an 80 bit hash code in a size_t if the size_t is only 64 bits.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top