commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <>
Subject [jira] Resolved: (MATH-151) MathUtils.round incorrect result
Date Tue, 04 Jul 2006 08:20:30 GMT
     [ ]
Phil Steitz resolved MATH-151:

    Resolution: Fixed

Patch applied.  Thanks!

I understand that the patch is not really satisfying, but it makes the code better and resolves
the reported problem.   A more elegant solution may be possible, but the patch improves the
code and resolves the reported problem, so it should be applied.  If we find a better way
to handle correct rounding of "bad" IEEE754 numbers, we can reopen or create a separate issue.

Thanks for the patch!

> MathUtils.round incorrect result
> --------------------------------
>          Key: MATH-151
>          URL:
>      Project: Commons Math
>         Type: Bug

>     Versions: 1.1 Final
>  Environment: Win2K, Sun JDK1.5.0_05 b05
>     Reporter: Buza Zoltán
>  Attachments: math-151.patch
> 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:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message