Closed GoogleCodeExporter closed 9 years ago
base-10 tolerance doesn't work, obviously - computers count in binary. But, a
maximum difference would be fine (something like
@EqualsAndHashCode(tolerance=0.000001) or @EqualsAndHashCode(tolerance=1e-10)).
We'd then generate (pseudocode): if (Math.abs(a-b) < tolerance)
concludeAandBareEffectivelyEqual();
Sounds probably okay, but, it's a rarely used setting. There are a lot of these
tiny cornercase situations, and if we allow for a setting on all of them, then
at some point @EqAHC has 35 settings, and I think the current situation is
better than that. Even if just because supporting all those options would
become an issue.
Furthermore, the general idea behind equals and hashCode implementations is
that you will use instances of this class in hashmaps or hashsets and the like.
Putting doubles/floats in objects that are intended to be keys in maps/sets
just seems like a really bad idea, which is why I'm not so sure we'd even want
this.
Unfortunately, we've got a list of feature requests as long as my leg, and I
don't think this one is going to make the cut.
Original comment by reini...@gmail.com
on 16 May 2013 at 5:43
Original issue reported on code.google.com by
ube...@gmail.com
on 14 May 2013 at 2:28