Feature suggestion: Add static equals methods to Float and Double

some-java-user-99206970363698485155 at vodafonemail.de some-java-user-99206970363698485155 at vodafonemail.de
Sun Jan 6 19:01:18 UTC 2019

My main goal was to provide a way where NaN is equal to NaN and I went with the behavior of the 
respective wrapper classes, Float and Double, which consider -0.0 and +0.0 as not equal.
The static method could be called "exactlyEquals" if that is better.

It might also depend on the usecase whether you want -0.0 being equal to +0.0. Maybe an additional 
method would be required for the case you are describing, e.g. "valueEquals" (though that can be 

> Hans Boehm <hboehm at google.com> hat am 6. Januar 2019 um 19:40 geschrieben: 
> What's the motivation for making it easier to spell a comparison method that tells me that -1.0*0.0 is not equal to 1.0*0.0? I would have thought that making this somewhat hard to write is a feature?
> I agree that there are cases in which this method is useful. But they all seem esoteric enough to me that it's not unreasonable for users to have enough expertise to write the method. Or at least the method should have a name that makes the unusual behavior explicit.

More information about the core-libs-dev mailing list