How to Round Decimal Calculations in Acrobat Form Fields
Question details
The user needs to round calculated decimal values in PDF form fields so that subsequent calculations use the rounded number rather than just changing the display format.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing PDF forms with calculation fields that require precise decimal rounding.
- Observed behavior
- Setting a number format to specific decimal places only alters the visual display, while underlying calculations continue using unrounded values, causing inconsistencies.
Before editing calculation scripts, ensure your PDF form is saved and you have access to the Prepare Form tools to modify field properties.
Use JavaScript to Round Calculated Values
Implement a custom calculation script using Math.round to ensure the actual underlying value is rounded, rather than just changing how it is displayed.
In PDF forms, setting the field format to 'Number' with two decimal places only changes how the value looks on the screen. To ensure later calculations use the mathematically rounded value, you must apply JavaScript to the field's calculation properties.
Open your PDF document in Acrobat, go to the Tools menu, and select the 'Prepare Form' option to enter form editing mode.
Right-click the calculation text field you want to round and choose 'Properties' from the context menu.
Navigate to the 'Calculate' tab in the Properties dialog and select the 'Custom calculation script' option.
Click the 'Edit' button and enter your script using the Math.round method. For example, to round to two decimal places, type: event.value = Math.round(your_calculation_here * 100) / 100;
Click 'OK' to apply the script, close the Properties window, and preview the form to test your calculation.

Edit and Manage PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to easily create, edit, fill, and manage interactive PDF forms without the high cost of premium software.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF tool.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view, edit, and interact with your form fields.
- 3. Edit Properties: Double-click any form field to adjust its appearance, format, and calculation properties easily.

Frequently Asked Questions
Why do my PDF calculations show rounding errors?
If you only change the field's display format to a set number of decimal places, the underlying unrounded decimal value is still used in subsequent calculations. You must mathematically round the value using a JavaScript calculation script to fix these errors.
How do I round to zero decimal places in PDF JavaScript?
To round to the nearest whole number, simply use the script event.value = Math.round(your_calculation); without multiplying or dividing by 100 in your custom calculation script.
Can I set default decimal places without scripts?
Yes, you can format a text field as a 'Number' and specify the decimal places under Field Properties > Format. However, keep in mind this only changes the visual display, not the actual mathematical value used in formulas.




