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

Calculation is roundering

Josman
Registered: Jul 15 2009
Posts: 31

I need help
I have two field calculation but the result is roundering
sample: Field A = 47.43
Field B = 4.86
47.43+4.86=52.29, but it is showing 52.30. what can I do to make my form not roundering.
I desig my form and I am using Acrobat 9 pro.
I usen the calculate tab sum.
I hope I can get help.
J

Josman

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
How are your fields A and B obtaining their values?

If the values are from computations, the value used in the calculations maybe different from the displayed values, and you should be rounding the results of the computing being entered into the field as part of the calculation. You could increase the number of decimal places to see what the real values being used in the calculation are or write a custom script to open the console and display the values being used for the addition and the result of t he computation.

George Kaiser

Josman
Registered: Jul 15 2009
Posts: 31
HI Gkaiseril, thanks for your response, here is how I created my form:
The field A is created by a sum of five others fields that these fiels also been created by a product of two fields. The multiplication actions are right but when the additions is performed is when start rounding the numbers. The field B is created by a number inserted by a customer. All my fields are set whit four decimals. When you said to write a custom script is to force a not to rounding the numbers? I hope this help you to see the problem that I have.
Thanks.
J

Josman

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You are not using what you think is being used in the calculations. So you will need to round each subcalculation as it is preformed.

So after you set the total value for "FieldA" you could add
// round event value using functionevent.value =  util.printf("%,1.2f", event.value); // round to 2 decimal places

George Kaiser

Josman
Registered: Jul 15 2009
Posts: 31
Sorry for to be late.
When you say to add this code you saying to put this code in the script place ( custom calculation script) of the FieldA? or I have to write the entire script of the calculation plus this code. not to use the "Value is the" in calculation
Thanks for your help.
J

Josman

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can add the code to the "Custom validation script" of the field you want rounded.

George Kaiser

Josman
Registered: Jul 15 2009
Posts: 31
Hello. I put this script to custom validation script but it is not calculating,
event.value = (this.getField("overhead").value +
this.getField("TOTAL").value +
this.getField("TOTAL LABOR").value);
event.value = util.printf("%,1.2f", event.value);
am I doing something wrong / my final field is Gran Total
Thanks.
J

Josman

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You put the calculation script
event.value = (this.getField("overhead").value +this.getField("TOTAL").value +this.getField("TOTAL LABOR").value);

in the Custom calculation field, so whenever one of the fields used in the calculation is updated the calculation script is executed.

You can keep the rounding code there or place it int he Custom validation. The validation code will be run when ever the field is updated.

George Kaiser

Josman
Registered: Jul 15 2009
Posts: 31
Thank you so much IT WORKS.
J

Josman