commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (MATH-1070) Incorrect rounding of float
Date Tue, 03 Dec 2013 23:51:35 GMT

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

Thomas Neidhart resolved MATH-1070.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 3.3

Fixed in r1547649.

According to BigDecimal.ROUND_UP, the value shall only be rounded up if the discarded fraction
is non-zero.

> Incorrect rounding of float
> ---------------------------
>
>                 Key: MATH-1070
>                 URL: https://issues.apache.org/jira/browse/MATH-1070
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: Windows 7, IntelliJ IDEA 10.5.4.
>            Reporter: Oleksandr Muliarevych
>            Priority: Critical
>             Fix For: 3.3
>
>
> package org.apache.commons.math3.util 
> example of usage of round functions of Precision class:
> Precision.round(0.0f, 2, BigDecimal.ROUND_UP) = 0.01
> Precision.round((float)0.0, 2, BigDecimal.ROUND_UP) = 0.01
> Precision.round((float) 0.0, 2) = 0.0
> Precision.round(0.0, 2, BigDecimal.ROUND_UP) = 0.0
> Seems the reason is usage of extending float to double inside round functions and getting
influence of memory trash as value.
> I think, same problem will be found at usage of other round modes.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message