Display Two Decimal Places Without Rounding in an Acrobat Form
Question details
The user needs a PDF form calculation to display two decimal places by truncating rather than rounding the result.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A calculated form field uses values from other fields and must show the result with exactly two decimal places.
- Observed behavior
- The desired result keeps two decimal places and discards subsequent digits without rounding.
Open the form in an Acrobat version that supports editing form fields, and identify the source and calculated field names. The example below uses source fields named NMS and CMS and calculates (NMS - CMS) / CMS.
Use a Custom Acrobat Calculation Script to Truncate Decimals
Use this method when a calculated form field must display two decimal places without rounding.
The script truncates toward zero, so a negative result such as -1.239 becomes -1.23. Using toFixed(2) alone would round the value instead.
In Acrobat, open the PDF and select All tools > Prepare a form. Double-click the calculated field to open its Properties.
In the field's Format tab, select None so the field's formatting does not apply separate rounding.
On the Calculate tab, select Custom calculation script and click Edit. Enter the following script, replacing NMS and CMS with your actual field names if necessary: var v1 = Number(this.getField("NMS").valueAsString); var v2 = Number(this.getField("CMS").valueAsString); function twoDecimals(value) { var scaled = value * 100; var truncated = scaled < 0 ? Math.ceil(scaled) : Math.floor(scaled); return (truncated / 100).toFixed(2); } if (v1 === 0 || v2 === 0) { event.value = ""; } else { event.value = twoDecimals((v1 - v2) / v2); }
Click OK to save the script, close field Properties, and preview the form. Enter test values in NMS and CMS, including values that produce negative results, and check the calculated field.

Work With PDF and Office Files in WPS Office
WPS Office is a free, lightweight alternative for working with documents, spreadsheets, presentations, and PDFs in a familiar interface. Its Office format compatibility makes it easy to bring existing files into your workflow; use Acrobat to edit and test the form calculation script described above.

Frequently Asked Questions
Why doesn't toFixed(2) truncate the calculation?
JavaScript's toFixed(2) rounds a number to two decimal places. Truncate the value first, then use toFixed(2) to display exactly two digits after the decimal point.
Where do I add the calculation script in Acrobat?
Open All tools > Prepare a form, double-click the result field, and go to Calculate > Custom calculation script > Edit.
Does Math.floor truncate negative numbers toward zero?
No. Math.floor moves negative numbers down to the next integer, away from zero. Use Math.ceil for a negative scaled value and Math.floor for a positive one to truncate toward zero.
Why is the calculated field blank when I enter zero?
The example script sets event.value to an empty string when either input is zero. The CMS value is also the divisor, so it must not be zero.




