Floating point error in percentage:product

Good morning,

We have recently updated our Polisadministratie component to the latest version and the necessary components for that.

Also with the new way of managing discount and surcharges. We only stumbled upon the following error, but cannot explain why it happens:

I’ve traced it down to the function discounted_premium_per_day() and it only happens to some of the coverages on a system version.

When I got the full expression from the function out of the architect:

{
systemversions,
premium_per_day().multperc(
Percentage:if(
SystemVersionDiscountAndSurcharges:count({
SystemVersionDiscountAndSurcharges,
this,
Boolean:and([
system_version.equals(parent),
discount.is_discount_percentages(),
percentage.equals(Percentage:load(1.0)),
discount.discount_or_surcharge.equals(NDiscountsurcharge:load(0))
])
}).equals(Int:load(0)),
Percentage:product({
SystemVersionDiscountAndSurcharges,
percentage,
Boolean:and([
system_version.equals(parent),
discount.is_discount_percentages(),
Boolean:not(
Boolean:and([
discount.discount_or_surcharge.equals(NDiscountsurcharge:load(0)),
percentage.equals(Percentage:load(1.0))
])
)
])
}),
Percentage:load(0.0)
)
)}

In that expression I traced it back to

Percentage:product({
SystemVersionDiscountAndSurcharges,
percentage,
Boolean:and([
system_version.equals(parent),
discount.is_discount_percentages(),
Boolean:not(
Boolean:and([
discount.discount_or_surcharge.equals(NDiscountsurcharge:load(0)),
percentage.equals(Percentage:load(1.0))
])
)
])
})

And it is in the percentage:product() function. It breaks on the below percentage (a negative number). The coverages with positive numbers it runs fine.

But the weird thing is if I call percentage:product(percentage:load(-0.5012)) in the system debugger it just returns it without any problems.

I’m at a loss what the problem could be.

Any help would be appreciated!

Kind regards,

Timothy

Since this is specific to your application I would rather do this in an SR if you need specific looking at your data.

Usually when something works directly this way in the expressiondebugger, the first thing I do is check if it still works by forcing the expression debugger to send the query to SQL (since the datahandler can do your example by itself).

In this case that would mean not typing percentage:product([percentage:load(value)]), but percentage:product([discounts:load(id).percentage])

If that produces a different result than the direct query, you would likely have found a bug.