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

George Smith updated MATH-1470:
-------------------------------
    Description: 
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

 

  was:
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

 


> 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
(v7.6.3#76005)

Reply via email to