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

Gareth Carter updated OFBIZ-6386:
---------------------------------
    Attachment: compareBigDecimals.png

compareBigDecimals.png shows the output of 5 different methods. The first table 
shows the result from the code in ofbiz - basically it treats all those values 
as equal to each other

The second table shows a slightly modified version where the BigDecimals are 
scaled and rounded up (eg 2.01 will become 2.010). The result for this scenario 
is the same as BigDecimal.compareTo where compareTo method ignores scale

The 4th table (BigDecimal.equals) is just there as a comparison and proves the 
result is false because the scale is different for each value

The 5th table, I have added only because <if-compare and <if-compare-field in 
minilang default to converting objects to their string representation before 
performing comparison (String.compareTo). The result is slightly different 
because compareTo compares lexicographically, 2.010 and 2.01 are the same 
numerically (ignoring scale), "2.010" and "2.01" are lexicographically different

> compareBigDecimals in org.ofbiz.minilang.method.conditional.Compare does not 
> compare certain values correctly
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-6386
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6386
>             Project: OFBiz
>          Issue Type: Bug
>    Affects Versions: Trunk
>            Reporter: Gareth Carter
>            Priority: Minor
>         Attachments: compareBigDecimals.png
>
>
> Moving the conversation from https://issues.apache.org/jira/browse/OFBIZ-6291 
> to this issue.
> compareBigDecimals scales down and rounds up meaning you lose information and 
> the comparison result is not as expected



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to