You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Andri Saar (JIRA)" <ji...@apache.org> on 2008/02/14 17:15:08 UTC
[jira] Updated: (WICKET-1344) BigDecimalConverter is not precise
[ https://issues.apache.org/jira/browse/WICKET-1344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andri Saar updated WICKET-1344:
-------------------------------
Attachment: BigDecimalConverter.patch
I've attached a quick fix that implements exactly what I described.
> 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
> Priority: Minor
> 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.