[ http://issues.apache.org/jira/browse/MATH-151?page=comments#action_12415774 ]
Phil Steitz commented on MATH-151: ---------------------------------- Sorry, messed up the link yet again. Best to just look at http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java?view=log or use a svn client to examine history. I also neglected to mention that part of the reason for the change to the new impl was performance. I played with some microbenchmarks to confirm this some time ago, seeing about 5x-8x improvement in the direct impl. It might be a good idea to do this testing rigorously. If we could characterize the inputs somehow that have "bad" IEEE754 representations, perhaps we could use the BigDecimal-based impl just for them. I don't see any reliable way to do that, though. > MathUtils.round incorrect result > -------------------------------- > > Key: MATH-151 > URL: http://issues.apache.org/jira/browse/MATH-151 > Project: Commons Math > Type: Bug > Versions: 1.1 Final > Environment: Win2K, Sun JDK1.5.0_05 b05 > Reporter: Buza Zoltán > > MathUtils.round(39.245, 2) results 39.24, however it should be 39.25, with > default rounding mode BigDecimal.ROUND_HALF_UP. > I found that internally MathUtils.round multiplies the given number by > 10^scale. > 39.245 * 100.0 results 3924.49999...5 , and after this the calculation is > not correct any more. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
