These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Calculate and limit results to 3 digits after decimal points

latheofheaven
Registered: Nov 3 2011
Posts: 10
Answered

Hello!
 
Adobe Acrobat X Pro:
 
I added a subtraction script to a field that calculates the total. I need to limit it to 3 spaces after the decimal point, however.
Here is my code:
var v1 = getField("D1 A1").value;
var v2 = getField("D1 B1").value;
event.value = v1 - v2;
 
Any suggestions, please?

"Things don't have purposes, as if the universe were a machine, where every part has a useful function. What's the function of a galaxy? I don't know if our life has a purpose and I don't see that it matters. What does matter is that we are." Ursula LeGui

My Product Information:
Acrobat Pro 10.0.1, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
You can set the number of decimal places to display on the field's "Format" tab.

If you need to round the result of the calculation to 3 decimal places, use the "util.printf()" method.

George Kaiser