10 Replies Latest reply on Mar 13, 2018 9:38 AM by gkaiseril

# Calculations - Rounding problems

I'm trying to setup sales tax forms that do all of the math for you after you enter in the key numbers. It works great except one little bug. The forms require all amounts to be rounded to the nearest dollar. No problem there. It's the overall total that's the problem. My form has two columns. In column total in (A) has the amount of 459 and the total in column (b) has 1,331. However the total of the two columns is 1,791. I know it because of the rounding in some of the previous cells. How do you get the last cell to use the rounded numbers instead of using the actual numbers in it's calculation? Thanks
• ###### 1. Re: Calculations - Rounding problems
How are you rounding those other values to the nearest dollar in the first place, and how are you setting the field values?

George
• ###### 2. Re: Calculations - Rounding problems
As for the rounding, I'm using the text field poperties. I select the format tab and select the number category and select no decimal place.

I start off typing in the beginning balances. Then they go through various basic calculations (addition, subtraction, & multiplication). I set these up using the calulate tab in the text field properties. I hope that answeres your question. Thanks again
• ###### 3. Re: Calculations - Rounding problems
The text field properties only change the value for display not computations. If you want the field value to be rounded for later computations you will need to write a rounding calculation. You can either use the "Math.round()" of JavaScript or the "util.printf() of Acrobat JavaScript. Since you will most likely be using this many times it would be best written as a document function.
• ###### 4. Re: Calculations - Rounding problems
Can you give me an example of how to write the script for that. I've tried the Math.round() but I've been unsuccessful. Basically I'm trying to write Math.round(Text#)+Math.round(Text#). Is there supposed to be more script before or after Math.round() to make it work properly? I really do appreciate your help.
• ###### 5. Re: Calculations - Rounding problems
If you are using LiveCycle Designer FormCalc:

// sum the rounded values of the field's Text1 and Text2 rounded to whole dollars
Round(Text1, 0) + Round(Text2, 0)

If you are using Acrobat's form foields, the custom script for the same example would be:

event.value = Math.round(this.getField("Text1").value) + Math.round(this.getField("Text2").value);
• ###### 6. Re: Calculations - Rounding problems
Awesome!!! Problem resolved. Thanks a ton for the help. I really appreciate it.
• ###### 7. Re: Calculations - Rounding problems

Hello ,dr friends i have an one doubt here i attached one sample Image.same type how can i create in Adobe live cycle Form..?the amount value calculated to Total Amount..?Pls Reply Me Form calc Code

• ###### 8. Re: Calculations - Rounding problems

Why do you want to do it in LCD? It's much better to use Acrobat.

• ###### 9. Re: Calculations - Rounding problems

Hi.! I'm new to Learn adobe live cycle, currently i'm working in Pvt company.so they Can give me a Task (Amount calculate then that amount calculate to added in total Amount). my self i try so many ways but did not get it answer.so i'm asking you.!Pls Explain me with screen Shot.

here using variable or without variable.?

• ###### 10. Re: Calculations - Rounding problems

LiveCycle can use a variation of Acrobat JavaScript as well as another language, FormCalc, see the LiveCycle forms for more help.

Adobe has LiveCycle Learn & Support and LIVECYCLE IN THREE DAYS VIDEO TRAINING which provide training.