@b0rk This is a lovely idea. Re "all integer values,"
there are some corner cases where Float64's interact with generic data structures like maps, and sets because often Float64's equality and comparison do not obey the contract needed by data structures that hash or sort internally.
This can lead to oddities around questions like "does this collection contain this zero"?
For example, The caveat in the docs for the boxing type for Java double explains how Java makes double arithmetic meet user's expectations most of the time while inter-operating with generic collections. Java collections use .equals to compare values, not primitive ==, which means that a set can separately contain positive and negative zero and may contain one but not the other.
import java.util.*;
public class TwoZeroes {
public static void main(String... argv) {
double x = Double.longBitsToDouble(
0x8000_0000_0000_0000L
);
Set<Double> someDoubles = new LinkedHashSet<>();
someDoubles.add(x);
System.err.println( // true
"x == 0: " + (x == 0.0D)
);
System.err.println( // true
"someDoubles contains x: " + someDoubles.contains(x)
);
System.err.println( // false
"someDoubles contains zero: " + someDoubles.contains(0.0D)
);
}
}
Negative zeroes might be rare in practice, but this might affect users who parse floating point numbers from a field pre-populated with a minus sign, like discount: -_____ or, iirc, when using rounding mode towards -Inf.