[
https://issues.apache.org/jira/browse/MATH-370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12865468#action_12865468
]
Phil Steitz commented on MATH-370:
----------------------------------
The method Mathutils.equals(double, double) was implemented for the reason that
in some cases, users may wish to treat doubles with NaN values as equal. The
internal classes that use it are the equals methods for statistics and
statistical aggregates. When these classes were defined, we decided that we
would treat two statistics or statistical aggregates as equal iff they had the
same values, including NaNs. So for example, two StatisticalSummaryValues
instances are equal iff they report the same values for all statistics, with
NaNs treated as "the same value." The MathUtils.equals(double, double) method
was introduced as a convenience method to do this kind of comparison. I guess
we could (deprecate and) change the name if it makes it look like all of our
computations are defining equals that way, which is certainly not the case. In
general, we do try to follow IEEE754. We agreed early on that we would
carefully document how NaNs are treated throughout Commons Math. We have
slipped a little over the years, but in the case of this method and the classes
that use it, the documentation is clear.
Sorry I misunderstood the point of the issue here. I now get your point that
naming the method "equals" makes it look like we are re-defining equals for
primitive doubles, which is not our intent. So maybe we deprecate the equals
method and rename something like "equalsIncludingNaN" or something simpler?
> NaN in "equals" methods
> -----------------------
>
> Key: MATH-370
> URL: https://issues.apache.org/jira/browse/MATH-370
> Project: Commons Math
> Issue Type: Bug
> Reporter: Gilles
> Priority: Minor
>
> In "MathUtils", some "equals" methods will return true if both argument are
> NaN.
> Unless I'm mistaken, this contradicts the IEEE standard.
> If nobody objects, I'm going to make the changes.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.