Expand my Community achievements bar.

Problem with calculation...

Avatar

Level 4

I have a field that calculates the sum of a few differend fields, This is the code I'm using

     sum (deductions[*])+dollar+percent2dollar

in

     form1.#subform[0].totalPremium::calculate - (FormCalc, client)


The field named percent2dollar is a hidden field that if a person elects to use a percent of their annual income instead of a dollar amount, it uses the following code:

     (annualSalary/percent)

in

     form1.#subform[0].percent2dollar::calculate - (FormCalc, client)

While the form functions properly, I get the following error upon entering an amount into the annualSalary field:

     Script failed (language is formcalc; context is

     xfa[0].form[0].form[1].#subform[0].percent2dollar[0]

     script=(annualSalary/percent)

     Error: arithmetic over/underflow.

Any idea what I need to change? I'm guessing I need to do something to where is doesn't calculate until a specific event or ignore the field if it is null. Thanks in advance!

1 Reply

Avatar

Level 10

The over/underflow appears if you do a multiplication or division with 0.

You can avoid such problems by wrapping you calculation script with an if-expression.

if (valueA ne 0 and valueB ne 0) then

     $ = valueA / valueB

else

     $ = 0

endif