You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Matt Juntunen (Jira)" <ji...@apache.org> on 2020/07/05 01:29:00 UTC
[jira] [Commented] (GEOMETRY-99) Inconsistent equals and hashCode
[ https://issues.apache.org/jira/browse/GEOMETRY-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17151450#comment-17151450 ]
Matt Juntunen commented on GEOMETRY-99:
---------------------------------------
Fixed in fc9272b2366d6b5944e1c1a9ecf568ff89f95a30
> Inconsistent equals and hashCode
> --------------------------------
>
> Key: GEOMETRY-99
> URL: https://issues.apache.org/jira/browse/GEOMETRY-99
> Project: Apache Commons Geometry
> Issue Type: Bug
> Reporter: Matt Juntunen
> Priority: Major
> Labels: beta1
>
> The following classes have inconsistent behavior between {{equals}} and {{hashCode}} in regard to +0.0 and -0.0:
> * EpsilonDoublePrecisionContext
> * Vector1D
> * Vector2D
> * Vector2D
> * SphericalCoordinates
> * PolarCoordinates
> * AffineTransformMatrix2D
> * AffineTransformMatrix3D
> * AxisAngleSequence
> This inconsistency comes from the use of == or {{Precision.equals}} to compare doubles in the {{equals}} method (which consider +0.0 and -0.0 to be equal) and {{Double.hashCode}} in the {{hashCode}} method (which returns different hash codes for +0.0 and -0.0). Hence, instances could be considered equal but have different hash codes.
> We should standardize on the use of {{Double.compare}} in {{equals}} and {{Double.hashCode}} in {{hashCode}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)