I am just going through my notes where I have Doubles
as HashMap
keys are bad that I vaguely remember using it for some online coding platform.
Are there any use cases and alternatives in dealing with Double
as Keys which you have dealt with in real world or interviews or coding problems?
I was thinking of the following, in case of an interview I can argue to use this and make my argument this is the best we can do.?
MyDouble(){
private final double original;
private final long value;
public MyDouble(double original) {
this.original = original;
this.value = Double.doubleToLongBits(original);
}
}