commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <>
Subject [jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation
Date Wed, 08 Aug 2012 09:50:12 GMT


Gilles commented on MATH-843:

bq. [...] but I do not like it.

I like it because it is more straightforward to understand while I must admit that I don't
fully understand your definition...
I've added a trivial unit test ("testMath841") that verifies the claim made in the documentation.

Please provide a unit test that makes your point clear, and I'll see no problem adding your
proposed comment in the Javadoc.

bq. [...] if executed in extended precision the result may be different [...]

I don't understand: The Javadoc now explicitly states "double-precision".
Let me know whether it can be made clearer.

> Precision.EPSILON: wrong documentation
> --------------------------------------
>                 Key: MATH-843
>                 URL:
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}}
states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not
numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> 	double e1 = 1-e;
> 	System.out.println(e);
> 	System.out.println(1-e);
> 	System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps !=
> I propose not to change the constant value, but to update the documentation. The value
{{Precision.EPSILON}} is 
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update 
> the api docs in this sense.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message