You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Johan Compagner (JIRA)" <ji...@apache.org> on 2008/04/09 16:14:24 UTC

[jira] Closed: (WICKET-1344) BigDecimalConverter is not precise

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

Johan Compagner closed WICKET-1344.
-----------------------------------

    Resolution: Fixed

patch applied

> BigDecimalConverter is not precise
> ----------------------------------
>
>                 Key: WICKET-1344
>                 URL: https://issues.apache.org/jira/browse/WICKET-1344
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Andri Saar
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.4-M1
>
>         Attachments: BigDecimalConverter.patch
>
>
> Currently, if we use the BigDecimalConverter class, it converts the values by first letting the NumberFormat to parse the value into a Double, which the BigDecimalConverter class in turn turns into a BigDecimal.
> Unfortunately such an implementation loses precision, for example if we enter "123.45" in a form, it can be converted to "123.45000000000001" or "123.44999999999999999" thanks to the conversion to a Double.
> Fixing the issue is rather simple: check if the NumberFormat you get is a DecimalFormat, and if yes, simply call format.setParseBigDecimal(true) and the NumberFormat will interpret the values correctly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.