Copy link to clipboard
Copied
I use Acrobat 10 to create invoices. Most Architects and Engineers bill by % complete... so when for example the design fee for a scope item is $1,500, when billed at 33% when done oin Word Processor or spreadsheet, if you have the program "doing the math", you must use the appropriate significant digits.
Using 33%,you will get $495 in your document
Using 33.33%,you will get $499.95 in your document
Ussing 33.33%,you will get $499.995 in your document, which will show as $500 in your document.
So if your document is formatted for Adobe PDF, isn't it supoosed to show what we see on the screen ?
No matter how many 3's I throw at it, I don't get $500.
Copy link to clipboard
Copied
What format does you use for the field?
Copy link to clipboard
Copied
Can you use a [value]/3 instead of a percentage?
You can use also, simple script (there is a forum here for that) to calculate and round up to the nearest interger.
Copy link to clipboard
Copied
If you use 33% of 1500 you can't get to 500 from 495 even with rounding (unless you use some custom rounding method).
If you use Math.round() you can get 500 if you use 33.33%.
Copy link to clipboard
Copied
You're not doing anything wrong, and the format used in the fields has nothing to do with the totals.
The issue is in understanding how the float values affect the programming of your JavaScript code, which as you've observed with the example provided, the float values are not in use.
You won't get the appropriate total because your equation, wether it be a simplified field notation or a custom calculation script is using string values.
When we use string values in an JavaScript arithmetic operation, the decimal fractions are ignored in the equation.
To avoid that, you must employ the float format in order to calculate accurately and with ease, and to include the significant digits as you pointed out.
For example:
var designFee = this.getField("Design Fee").value;
var billedAt = this.getField("Billed At").value;
var total = (designFee * (billedAt / 100));
///calculate the total value with float format ///
event.value = util.printf("%.0f", total);
Math.round, on the other hand, is a way of forcing an equation to round up to the nearest integer value; not to the nearest tens, hundreds, thousands (unless you manually employ the decimal rounding rules).
In more complex arithmetic operations, the Math.round(), method (to include other methods of truncating large numbers) it may throw innacurate results down the road; specifically if you're charging money to customers... But I maybe totally wrong with this observation.
In any case, you may want to keep it as accurate as possible.
See here about rounding decimals: