commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] Commented: (MATH-151) MathUtils.round incorrect result
Date Sun, 11 Jun 2006 00:27:30 GMT
    [ http://issues.apache.org/jira/browse/MATH-151?page=comments#action_12415723 ] 

Phil Steitz commented on MATH-151:
----------------------------------

Thanks for digging into this, Luc.

I agree that the source of the problem here is in the decimal - binary conversion; but I don't
want to close this as "invalid" or "wontfix" until we have exhausted all practical means to
address the problem from the user standpoint.  In other words, I would prefer to find a workaround
if that is possible.  

One possibility is to revert to the implementation in R226479 or earlier.  See http://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java?revision=226479

where we used BigDecimal rounding.  We changed this partly for efficiency, partly to address
http://issues.apache.org/jira/browse/MATH-32, which we would have to address in some other
way if we go that route.

Ideas or patches welcome!

> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message