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

Beginner - round subtraction calculation

tashfaux
Registered: Jul 16 2007
Posts: 4

I am a beginner, help would be appreciated!
I have a form that has two calculations dividing by 11 and showing the result with no decimal places. I then want to subtract one of the answers from the other. Problem is the subtraction is using the complete number (with decimals) and I want the subtraction to be the rounded numbers. Here is the script I have:
 
var a = this.getField('G9');
var b = this.getField('G20');
 
event.value = (a.value - b.value);
 
I want the rounded value of G20 to be subtracted from the rounded value of G9.
 
Thanks in advance. . .

My Product Information:
Acrobat Pro 6.0.0, Windows
dbaker
Expert
Registered: Feb 10 2006
Posts: 413
Hi --

Quick fix for you.

-- Open the Text Field Properties dialog box for your fields.

-- Click the Format tab, and select Number from the Select format category dropdown list.

-- Choose the number of decimal places, which is 2 by default.

-- Click Close.

Repeat the process for your G9, G20, and the calculation result field.

donna.

A prolific author and writer of many Acrobat books, as well as books on graphic and Web design software.
Donna lives on a lakeshore in central Canada, where all manner of wildlife from muskrats to coyotes come to call.

tashfaux
Registered: Jul 16 2007
Posts: 4
I have already done that, it doesn't work though. It uses the cents in the calculation and then rounds. Eg G9 is G8 div by 11 and G20 is G19 div by 11. Sometimes it will be right, but depending on the figures it can be $1 out. ie, the example I have been using is 39156 div by 11 (3559.636363) and then 8816 div by 11 (801.4545454) I want the subtraction to be 3560-801 = 2759, but I am getting 3559.64-801.45=2758.19 and therefor rounding to 2758.