[
https://issues.apache.org/jira/browse/TRINIDAD-1124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606956#action_12606956
]
Matthias Weßendorf commented on TRINIDAD-1124:
----------------------------------------------
Hi Ed,
the testcase doesn't reproduce it. Here is why:
Converter converter = application.createConverter("javax.faces.Number");
...
converter.getAsObject(getFacesContext(), text,
stringToConvert);
...
BEFORE your change, it would return a Double, with the Value 333.111, which is
correct.
Now, it returns a BigDecimal, which is more correct, but still the value is
333.111 (as wanted)
But... when the bean value is actually BigDecimal, it (the Double object) would
be converted into a BigDecmial,
by EL engine with something like:
new BigDecimal(doubleObjectReturnedFromTheConverter.doubleValue());
this... would cause the problem. Therefore I provided these two simple tests in
my first comment:
-new java.math.BigDecimal(new Double(333.111).toString())
-new java.math.BigDecimal(new Double(333.111).doubleValue())
the last is "wrong" in the sense of why the bug was filed... (means a value
like 333.110984654754...)
So you can reproduce it an application such as:
<tr:inputText value="#{bean.number}" ...>
<tr:convertNumber />
</tr:inputText>
Where "number" property is actually BigDecimal and... the converter actually
returns a double (which WAS the case).
Is this more clear ?
> numberconverter has issue with bigdecimal
> -----------------------------------------
>
> Key: TRINIDAD-1124
> URL: https://issues.apache.org/jira/browse/TRINIDAD-1124
> Project: MyFaces Trinidad
> Issue Type: Bug
> Reporter: Matthias Weßendorf
> Assignee: Matthias Weßendorf
> Fix For: 1.0.9-core, 1.2.9-core
>
>
> Due to a potential bug in BigDecimal there is a bug, when you use BigDecimal
> with a NumberConverter.
> Like
> <tr:inputText value="#{bean.number}" ...>
> <tr:convertNumber />
> </tr:inputText>
> For instance, when the entered value is "333.111" the actual stored value is
> 333.1109999999999899955582804977893829345703125
> There is a mathematic explanation for that in here:
> http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.