[ 
https://issues.apache.org/jira/browse/MATH-1386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15504032#comment-15504032
 ] 

Gilles commented on MATH-1386:
------------------------------

bq.  When dealing with double I've always used 2.220446049250313E-16 for 
epsilon.

What is the definition of {{epsilon}} in the above?

bq. You have it defined in org.apache.commons.math.util.MathUtils as 
1.1102230246251565E-16

In recent versions of Commons Math, this constant has been defined in class 
{{Precision}}.

The Commons Math documentation agrees with the following:
{noformat}
eps = 1.1102230246251565E-16
1 + eps = 1.0
1 + 2 * eps = 1.0000000000000002
1 + nextUp(eps) = 1.0000000000000002
{noformat}

See also MATH-843.


> EPSILON value in  org.apache.commons.math.util.MathUtils seems like half of 
> what it should be
> ---------------------------------------------------------------------------------------------
>
>                 Key: MATH-1386
>                 URL: https://issues.apache.org/jira/browse/MATH-1386
>             Project: Commons Math
>          Issue Type: Bug
>         Environment: win 7
>            Reporter: Brian S. McCormick
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I've always used 1.1920929E-7 for dealing with float epsilon values. When 
> dealing with double I've always used 2.220446049250313E-16 for epsilon.
> You have it defined in org.apache.commons.math.util.MathUtils as 
> 1.1102230246251565E-16 which is half what I think it should be.
> I come up with these numbers using the following:
> float fEps = Float.intBitsToFloat(Float.floatToIntBits(1f) + 1) - 1;
> double dEps = Double.longBitsToDouble(Double.doubleToLongBits(1) + 1) - 1;
> Am I correct? I don't really know. I do know that float epsilon in every 
> legacy C/C++ compiler etc I have ever used is defined as about 1e-7 and this 
> is the value using the formula for fEps above. When I started doing comps 
> using doubles instead of floats I started using the formula for dEps above 
> which looks to me like the equivalent for double numbers. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to