Copy link to clipboard
Copied
Please help! Trying to beat a work deadline. The rounding issue can clearly be seen if I can send someone the pdf
Copy link to clipboard
Copied
Acrobat and Excel behave in a very similar manner for this type of calculation.
Without any formatting or rounding 7 * 0.535 is displayed as 3.7450 the total of 5 iterations is 18.725.
Formatted to 2 decimal places the displayed value is 3.75 the total of 5 iterations is 18.73.
Individual result values rounded to 2 decimal places the displayed total is 3.75 the total of 5 iterations is 18.75.
When dealing with financial reports or government forms the result of each calculation should be rounded to the required number of decimal places for the report or form.
Rounding Example in PDF and Excel
Since Acrobat does not include a rounding function, a user written rounding function has been added as a document level function to the PDF. This function was adapted form a PDF rounding examples developed by D.P. Story.
Most individuals when computing this type of problem subconsciously round the individual results to 2 decimal places, but computers do not.
Copy link to clipboard
Copied
You might have to tell us a lot more about it...
Copy link to clipboard
Copied
I have a formula that is miles times .535. The answer is rounded to 2 decimal points. I have 5 rows with this calculation
Then I have a total that is the the sum of the aforementioned rows. That total is rounded to 2 decimal points. Here is what my sheet looks like:
Miles Mileage cost
7 $3.75
7 $3.75
7 $3.75
7 $3.75
7 $3.75
Total:
35 $18.73
It should read $18.75
Can you help? Thanks so much!
Copy link to clipboard
Copied
Result of 7 * 0.535 is 3.745 formatted as 3.75
Result of 5 * 3.745 is 18.725 formatted as 18.73
Copy link to clipboard
Copied
Make sure your formula has is "=round(mile*rate),2)"
For total use "sumproduct(FROM:TO)
Understand your existing total is more correct.
Miileage | 0.535000 | |||
Error | ||||
7.000000 | 3.7450 | 3.75 | -0.0050 | |
7.000000 | 3.7450 | 3.75 | -0.0050 | |
7.000000 | 3.7450 | 3.75 | -0.0050 | |
7.000000 | 3.7450 | 3.75 | -0.0050 | |
7.000000 | 3.7450 | 3.75 | -0.0050 | |
18.7250 | 18.75 | -0.0250 |
Copy link to clipboard
Copied
What you are experiencing is the result of the "Format" setting that only changes the displayed value of a field and not the actual value of the field. If you increase the number of the decimal points in the formatting settings, you see a result in the displayed value.
"round" is not a function in JavaScript nor Adobe Acrobat JavaScript.
If this is a user written function can you please post the code and instructions on how to add it to a PDF.
Copy link to clipboard
Copied
hermanw28045343 wrote
Make sure your formula has is "=round(mile*rate),2)"
For total use "sumproduct(FROM:TO)
...
Info: Adobe Acrobat and MS Excel are different products.
Copy link to clipboard
Copied
Acrobat and Excel behave in a very similar manner for this type of calculation.
Without any formatting or rounding 7 * 0.535 is displayed as 3.7450 the total of 5 iterations is 18.725.
Formatted to 2 decimal places the displayed value is 3.75 the total of 5 iterations is 18.73.
Individual result values rounded to 2 decimal places the displayed total is 3.75 the total of 5 iterations is 18.75.
When dealing with financial reports or government forms the result of each calculation should be rounded to the required number of decimal places for the report or form.
Rounding Example in PDF and Excel
Since Acrobat does not include a rounding function, a user written rounding function has been added as a document level function to the PDF. This function was adapted form a PDF rounding examples developed by D.P. Story.
Most individuals when computing this type of problem subconsciously round the individual results to 2 decimal places, but computers do not.
Copy link to clipboard
Copied
Computers do the calculations using the binary number system, so as many are aware the decimal vlaues do not always convert to a rational value but result in an irrational value. The resulting values is stored as decimal floating point values.
The Math.round method works only on intiger values or whole numbers. One can multiply by 100 use the Math.round method and divide the result by 100 and for most values come up with the correct result but not in all cases. It is possible to set the displayed value of a field to 2 decimal places, but this does not change the actual computed value.
If one needs to round the actual value of the calculation to 2 decimal places then one needs to write a custom function to perform the rounding unless one wnats to repeat the code for rounding at every situation where the result needs to be rounded.
The following document level function will decimal round a number to the power of 10 places. For 2 decimal places or 1/100 th one would use a value of -2 for the decimal level to. A sample file of rounding a value to 2 decimal places.