commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Smith (JIRA)" <j...@apache.org>
Subject [jira] [Created] (MATH-1470) Precision.round(double...)'s use of Double.toString(x) rounds twice resulting in inaccuracy
Date Tue, 02 Oct 2018 21:18:00 GMT
George Smith created MATH-1470:
----------------------------------

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


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)

Mime
View raw message