[jira] [Commented] (OFBIZ-6386) compareBigDecimals in org.ofbiz.minilang.method.conditional.Compare does not compare certain values correctly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-6386) compareBigDecimals in org.ofbiz.minilang.method.conditional.Compare does not compare certain values correctly

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-6386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15335601#comment-15335601 ]

Jacques Le Roux commented on OFBIZ-6386:
----------------------------------------

Thanks Mridul,

I was thinking "why Adrian complicated those things will always remain a mystery" then I got to OFBIZ-6291 by chance. After reading https://issues.apache.org/jira/browse/OFBIZ-6291?focusedCommentId=14510685, quoted here for convenience
{quote}
Mini-language is a scripting language. One of the nice things about scripting languages is you can compare things like decimal values without worrying about the underlying implementation. That is what the current implementation does: 2 == 2.0 == 2.000000.

If we were to compare BigDecimal precision, then we lose the scripting abstraction, PLUS pretty much everything that uses Mini-language will break.

If you need to compare BigDecimal precision, then you can use a scriptlet: groovy:fooBigDecimal.equals(barBigDecimal).
{quote}

and reviewing the v1.patch I agree we should apply and cross fingers that Adrian was wrong about
bq. If we were to compare BigDecimal precision, then we lose the scripting abstraction, *PLUS pretty much everything that uses Mini-language will break.*
I guess he crossed an issue, at least once, and that's why he put this piece of code. Also maybe he did not see the issues Gareth raised and focused on the "2 == 2.0 == 2.000000." aspect. I hope it's the second but I doubt, anyway should not be a big deal :)

> 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
>            Assignee: Mridul Pathak
>            Priority: Minor
>         Attachments: compareBigDecimals.png, v1.patch, v2.patch
>
>
> Moving the conversation from 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)