The equals methods on Float and Double are *not* just wrappers around the corresponding == operator because the IEEE 754 == operator does *not* define an equivalence relation. The properties of an equivalence relation are broken by NaN (since NaN is not equal to itself) and by -0.0/+0.0. While -0.0 and +0.0 compare as equal, they are distinct values that can change the value of a result of an operation; for example, +1.0/+0.0 is positive infinity while +1.0/-0.0 is negative infinity.
This situation could be more clearly motivated than the oblique "This definition allows hash tables to operate properly." statement equals methods.
This situation could be more clearly motivated than the oblique "This definition allows hash tables to operate properly." statement equals methods.
- relates to
-
JDK-8294539 Augment discussion of equivalence relations on floating-point values
-
- Resolved
-
-
JDK-8240632 Note differences between IEEE 754-2019 math lib special cases and java.lang.Math
-
- Resolved
-
-
JDK-8261123 Augment discussion of equivalence classes in Object.equals and comparison methods
-
- Resolved
-
-
JDK-8256861 Records: Details of implicitly declared equals method has been superseded in implementation
-
- Resolved
-
(1 links to)