How to Prevent FormCalc Division by Zero Overflow Errors in PDF Forms
Question details
The user encounters an overflow or underflow error in a LiveCycle or AEM PDF form when a calculation attempts to divide by a zero value field.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Opening or interacting with a dynamic PDF form where the initial or entered divisor field values are zero.
- Observed behavior
- The form application triggers an overflow or underflow error due to a mathematical division by zero inside the FormCalc script.
Ensure you have editing access to the PDF form's script editor and verify the exact names of the calculated fields before modifying the formulas.
Add Conditional Logic to Check for Zero Values
Prevent the division by zero error by wrapping the division formula in an If-Condition that checks the divisor first.
When a dynamic form opens, number fields often default to zero. If your script attempts to calculate a percentage or ratio immediately, dividing by these zero values triggers an overflow error. Adding conditional logic ensures the division only occurs when valid data is present.
Open your PDF form in edit or design mode and select the specific field where the calculation occurs.
Find the division operation in your FormCalc script (e.g., UtilizedContractValue / ApprovedContractValue).
Add an 'if' statement to verify the divisor is greater than zero: if (ApprovedContractValue == 0) then $ = 0
Append the 'else' condition to execute the division when a valid number is entered: else $ = UtilizedContractValue / ApprovedContractValue endif.

Edit and Fill Interactive PDF Forms with WPS Office
While advanced XFA scripting is native to specific enterprise tools, WPS Office offers a highly capable PDF editor that allows you to effortlessly view, edit, and fill standard interactive PDF forms without encountering legacy scripting errors.
- 1. Open the PDF File: Launch WPS Office and click on the 'PDF' tab to open your interactive form document.
- 2. Access Form Tools: Navigate to the 'Form' or 'Fill & Sign' menu to interact with the input fields safely.
- 3. Input Data Validly: Enter your numeric or text values into the fields; WPS handles standard form validations automatically.
- 4. Save as Flattened PDF: Once completed, you can export or print the document as a flattened PDF to securely preserve the calculated values.

Frequently Asked Questions
Why does my PDF form show a division by zero error automatically upon opening?
When the form initially loads, number fields default to zero. If your calculation script is set to run automatically and attempts to divide by an empty field, the system immediately triggers a division by zero overflow error.
Can I use JavaScript instead of FormCalc to fix this?
Yes, if your form editor supports both, you can rewrite the script in JavaScript. You would similarly use an 'if' statement, such as checking 'if (ApprovedContractValue.rawValue !== 0)' before running the division.
How do I leave the field blank instead of showing a zero result?
In your FormCalc condition, instead of writing 'then $ = 0', you can assign a null value by writing 'then $ = null'. This prevents the field from displaying an arbitrary zero before the user fills out the form.




