News for hackers. Stuff that matters.
Re:String.hashCode() is plenty unique by Someone on Saturday August 11, 2018 @07:37AM (#17739282)
”resulted in 1 collision. A “fair” hash function would generate an expected 1.44 collisions over this data. String.hashCode() outperforms a fair hash function significantly”

I doubt that is significant, and you needn’t even lookup the confidence intervals. Think of it this way: if you ran one more experiment with similar data, if that perfectly good hash were to approximate that 1.44 collision on average between the two experiments, is has to have at least one experiment where it has zero or one collision.

Also, string hashing has a few requirements that I think are more important than having an optimal probability of collisions:

- it has to work well on typical 16-bit text strings, where most of the time, half the bytes are zero and most of the other bytes have only fivefold six bits that vary (that’s why there are so many collisions in two character strings: they are four bytes long, but, at best, differ in only about 10 bits)

- it has to be fast.

There are no comments on this comment yet.