How to Round a PDF Form Calculation at the Third Decimal Place
Question details
The user needs to configure a PDF form calculation so that it rounds the result to two decimal places, specifically rounding up when the third decimal digit is 4 or greater, rather than the standard mathematical threshold of 5.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form that requires customized financial or sales-tax rounding rules.
- Observed behavior
- Standard PDF number formatting uses default rounding (rounding up at 5). The goal is to force the calculation to use a non-standard threshold (rounding up at 4) via custom scripting.
Ensure you are using a PDF editor that supports editing interactive form fields and allows adding custom JavaScript scripts to field properties.
Use a Custom JavaScript Calculation Formula
Apply a custom JavaScript snippet to the result field's calculation properties to override standard rounding logic and adjust the rounding threshold.
Standard PDF calculation formats automatically round up when the next decimal is 5 or higher. To round up when the third decimal is 4 or higher, you cannot rely solely on the built-in number formatting. You must calculate the exact value via script, shift the decimal using a custom mathematical formula, and output the result.
Open your PDF document in your PDF editor and navigate to the 'Form' tab to enable form editing mode.
Right-click the specific text field where the calculated result should appear and select 'Properties' from the context menu.
Navigate to the 'Calculate' tab, select the 'Custom calculation script' radio button, and click the 'Edit' button.
Input the following JavaScript, replacing 'YOUR_CALCULATION' with your actual math logic or variable: event.value = Math.floor(YOUR_CALCULATION * 100 + 0.6) / 100;
Go to the 'Format' tab, select 'Number' as the format category, and set it to display 2 decimal places with your preferred currency separator style.

Easily Manage PDF Forms and JavaScript Calculations in WPS Office
WPS PDF provides robust, easy-to-use form editing features, allowing you to insert text fields, apply custom JavaScript calculations, and format number outputs directly within your documents.
- 1. Open WPS PDF: Launch WPS Office and open your interactive PDF form document.
- 2. Access Form Mode: Navigate to the 'Form' tab on the top ribbon to view and edit interactive form fields.
- 3. Edit Field Properties: Double-click or right-click the calculation field, select 'Properties', and add your custom JavaScript script under the Calculate tab.

Frequently Asked Questions
Why doesn't the standard PDF number format round up at 4?
Standard number formatting universally adheres to basic mathematical rounding rules, which round up starting at 5. To shift this threshold specifically to 4, you must bypass the standard behavior using custom programmatic logic (JavaScript).
How does the Math.floor formula change the rounding threshold?
By multiplying the target value by 100 and adding 0.6 (instead of the standard 0.5) before applying the Math.floor() function, any third decimal of 4 or higher will push the calculation over the next integer threshold. Dividing by 100 then restores the correct decimal placement.
Can I use standard calculation options instead of custom JavaScript?
Standard calculation options, such as sum or product built into the PDF field properties, only use default rounding. If your document requires a non-standard rounding rule, you must select the 'Custom calculation script' option.




