commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-904) FastMath.pow deviates from Math.pow for negative, finite base values with an exponent 2^52 < y < 2^53
Date Thu, 22 Nov 2012 09:44:59 GMT

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

Thomas Neidhart commented on MATH-904:
--------------------------------------

ah ok, thanks a lot, I found also an explanation here [http://en.wikipedia.org/wiki/Double-precision_floating-point_format]
                
> FastMath.pow deviates from Math.pow for negative, finite base values with an exponent
2^52 < y < 2^53 
> ------------------------------------------------------------------------------------------------------
>
>                 Key: MATH-904
>                 URL: https://issues.apache.org/jira/browse/MATH-904
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Thomas Neidhart
>             Fix For: 3.1
>
>
> As reported by Jeff Hain:
> pow(double,double):
> Math.pow(-1.0,5.000000000000001E15) = -1.0
> FastMath.pow(-1.0,5.000000000000001E15) = 1.0
> ===> This is due to considering that power is an even
> integer if it is >= 2^52, while you need to test
> that it is >= 2^53 for it.
> ===> replace
> "if (y >= TWO_POWER_52 || y <= -TWO_POWER_52)"
> with
> "if (y >= 2*TWO_POWER_52 || y <= -2*TWO_POWER_52)"
> and that solves it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message