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.

Reply via email to