You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2023/07/18 08:22:00 UTC

[jira] [Resolved] (MATH-1470) Precision.round(double...)'s use of Double.toString(x) rounds twice resulting in inaccuracy

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

Gilles Sadowski resolved MATH-1470.
-----------------------------------
    Resolution: Feedback Received

Issue to be solved in "Commons Numbers" (NUMBERS-199).

> Precision.round(double...)'s use of Double.toString(x) rounds twice resulting in inaccuracy
> -------------------------------------------------------------------------------------------
>
>                 Key: MATH-1470
>                 URL: https://issues.apache.org/jira/browse/MATH-1470
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.6.1
>            Reporter: George Smith
>            Priority: Major
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The use of Double.toString( x ) in the creation of the BigDecimal used by the Precision.round(double...) methods introduces a rounding that can then generate incorrect results when the rounding is applied to the BigDecimal.  Whenever possible rounding should only be applied to the most accurate value available.  Switching the BigDecimal construction to use the double value directly resolves the problem.
>  
> This problem can be seen by running the main method of the com.altoros.floatingpoint.PrecisionProblem class in the repo hosted at: [https://github.com/Altoros/precision-problem]
>  
> George
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)