To test whether primitive float or double values are equal according to
`Float.equals` and `Double.equals` you either have to create wrapper instances
for them (possible performance decrease), use the respective static `compareTo`
(verbose) or have to use the appropriate methods (`floatToIntBits` /
`doubleToLongBits`) (verbose and error-prone since you could confuse them with
the other conversion methods).
It would be good to provide static methods for testing for equality of the
primitive values:
// In Float.java
public static boolean equals(float a, float b) {
return Float.floatToIntBits(a) == Float.floatToIntBits(b);
}
// In Double.java
public static boolean equals(double a, double b) {
return Double.doubleToLongBits(a) == Double.doubleToLongBits(b);
}
This would be very convenient for developers and prevent them from writing
(possibly faulty) code for this themselves.