DMN Simulator with rounding error?

Hi community,

i have a javascript expression to evaluate which produces as output a double value.

var a = (((Input_A*0.23)/1000)*1.1);
if (a < 40.00)
a = 40.00;
var result = (a *((100-discount_a)/100) * ((100-discount_b)/100));

Given that Input_A = 1500000
dicount_a, discount_b = 0

The expected result should be 379.5 but the online simulator returns 379.50000000000006

How can I fix this?

Kind regards

Hi @Dominik,

it seems that some intermediate result can’t be represented as a double floating point value. What worked for me is to change var a = (((Input_A*0.23)/1000)*1.1); to var a = (((Input_A*0.23)/10000)*11);.

I can’t tell you what went wrong exactly, but you can try to break up your formulas to find out where the error occurs if you run into this problem again :slight_smile: