You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Luc Maisonobe (JIRA)" <ji...@apache.org> on 2011/03/23 21:33:05 UTC

[jira] [Closed] (MATH-475) MathUtils.equals(double, double, double) does not agree with Javadoc

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

Luc Maisonobe closed MATH-475.
------------------------------


Closing issue as it was included in version 2.2, which has been released

> MathUtils.equals(double, double, double) does not agree with Javadoc
> --------------------------------------------------------------------
>
>                 Key: MATH-475
>                 URL: https://issues.apache.org/jira/browse/MATH-475
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 3.0
>
>
> MathUtils.equals(double, double, double) does not agree with its Javadoc.
> The Javadoc says:
> "Returns true if both arguments are equal or within the range of allowed error (inclusive)."
> However the following test fails:
> {code}
> double top=1.7976931348623184E16;
> double pen=1.7976931348623182E16;
> double diff=Math.abs(top-pen);
> assertTrue(MathUtils.equals(top, pen, 1.0)); // OK - implies the difference is <= 1.0
> assertTrue("expected < 1.0, but was: "+diff,diff <= 1.0); // reports: expected < 1.0, but was: 2.0
> {code}
> This discrepancy is because the equals(double, double, double) method also checks to see if the numbers are within one ULP of each other.
> Either the Javadoc needs to be corrected, or the code needs to be corrected to drop the ULP comparison.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira