Value object equality & floating-point values
John Rose
john.r.rose at oracle.com
Tue Feb 13 20:22:49 UTC 2024
On 12 Feb 2024, at 13:00, Dan Smith wrote:
>> For each `float` or `double` field in a value class, the constructor will generate normalization code
Indeed we considered this, but consider the tradeoff:
Benefit: Somebody who is looking very closely indeed at NaNs sees a different op== behavior. That person is pleased, yay!
Cost: Everybody who stores floats and doubles in value classes sees object creation slow down due to branchy normalization logic, at least wherever hardware creates unpredictable NaNs and/or NaNs that don’t fit the Java model of “good” NaNs.
The cost is too risky, just to please a few NaN-detectives.
More information about the valhalla-spec-observers
mailing list