logoalt Hacker News

Terr_last Tuesday at 9:46 AM0 repliesview on HN

This is calling up dim old memories of Java (which I haven't used in years) and boxing primitive float values into Float objects which provide their own implementation of equals() and hashCode().

AFAICT the pre-hash values come from this method [0] which returns an integer which is a 1:1 representation of the float bytes except that NaNs are all collapsed to one canonical form. So at least at this phase, it doesn't quantize any virtually-equal floats together.

Skimming an implementation of HashMap [1], I didn't notice any obvious "do something special for Floats" code.

[0] https://docs.oracle.com/en/java/javase/17/docs/api/java.base...

[1] https://github.com/openjdk/jdk/blob/master/src/java.base/sha...