DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Add Objects.equal methods for primitives. #1546

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The primary reason for the request is to support Float.floatToIntBits & 
Double.doubleToLongBits comparisons.

The secondary reason is to compare primitives with the same pattern as objects 
(tho they obviously don't need the null check.

Original issue reported on code.google.com by karl...@gmail.com on 27 Sep 2013 at 7:57

GoogleCodeExporter commented 9 years ago
We're not going to do this, for a few reasons.

1) It would be nonsensical and weird to provide equality methods in the Objects 
class for non-objects.
2) Objects.equal already works for primitives (by autoboxing), and already 
provides the behavior you want on floats and doubles.
3) If your concern is the boxing overhead, there are already efficient and 
readable ways to compare floats and doubles with the same semantics as 
Double.equals(Object) without boxing, e.g. Double.compare(a, b) == 0.  (I just 
tested this.)

Original comment by lowas...@google.com on 27 Sep 2013 at 8:07

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08