
8 Dec
2024
8 Dec
'24
6:31 p.m.
So, for example, if you have a 32 bit hash function and you need 64 bits, this is how you would do it, ordered from best to worst:
// as good as possible uint64_t f1( Hash& hash ) { uint32_t r1 = hash.result(); uint32_t r2 = hash.result(); return (uint64_t(r1) << 32) | r2; }
// not that bad, but worse than the above uint64_t f2( Hash& hash ) { return get_integral_result
( hash.result() ); }
All that leads me to the thought that I've got get_integral_result wrong;
it should take the hash algorithm directly, not its result, and should
invoke result() as many times as needed to obtain the necessary
number of bits.
// best
uint64_t f0( Hash& hash )
{
return get_integral_result