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] Created: (WICKET-1344) BigDecimalConverter is not precise

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.


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

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ 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.


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

Posted by "Andri Saar (JIRA)" <ji...@apache.org>.
     [ 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.


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

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner updated WICKET-1344:
------------------------------------

    Fix Version/s: 1.4-M1
         Assignee: Johan Compagner

We can only do this for Wicket 1.4 because the method we need to call is java 5

> 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.