That is one solution but it would be nice to fix JUEL. By the way I just had quick look at the calculate method and if you don't set a decimal-scale then 2 is used which seems a bit of a worry as well.

Regards
Scott

On 10/09/2009, at 7:34 PM, Vince Clark wrote:

I don't know much about UEL but did run into a rounding issue.

I chose to instead use <calculate> so I could control precision.

Vince Clark
www.globalera.com
vcl...@globalera.com
(303) 493-6723 office
(303) 523-4843 cell


----- Original Message -----
From: "Scott Gray" <scott.g...@hotwaxmedia.com>
To: dev@ofbiz.apache.org
Sent: Thursday, September 10, 2009 1:27:08 AM GMT -07:00 US/Canada Mountain
Subject: JUEL rounding issues

Out of curiosity today I ran a couple of simple tests using JUEL's
numeric expressions and the results are a bit worrying, here's some
example code:
<set field="value1" value="0.0001" type="BigDecimal"/>
<set field="value2" value="10" type="BigDecimal"/>
<set field="resultValue" value="${value1 / value2}" type="BigDecimal"/>
<log level="always" message="${resultValue}"></log>

and here are some example results:
0.0001 / 10 = 0
10 / 3 = 3
10.89879 + 6.8978336 = 17.797
10.89879 * 6.8978336 = 75.178
10 - 2.5001 = 7.5

I don't have time right this minute to fix it so just reporting here
so people are aware.  Adrian, I'm not asking you to fix it but if you
have any pointers or suggestions they'd be most welcome.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to