[ 
https://issues.apache.org/jira/browse/GEOMETRY-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Matt Juntunen updated GEOMETRY-99:
----------------------------------
    Labels: beta1  (was: )

> 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)

Reply via email to