Copy link to clipboard
Copied
Hi,
Is there a script that will turn off rounding and only show two decimal points? Iām working on a worksheet that calculates a student GPA , and I need it to truncate after the second decimal point. For example, instead of 3.236 rounding to 3.24, I need it to show as 3.23.
Thank you.
Copy link to clipboard
Copied
Acrobat/Reader stores the results of calculations in 16 digit floating point numbers but calculates using binary numbers. This results in having a slightly different answer than when the computation is done with paper and pencil. Remove all formatting from the result field and observe the resulting value. Also the displayed value as set by the Format tab is the rounded value of the results of the computation. If one uses the custom calculation script then one can force the result of the calculation using the Math.ceil or the Math.floor methods to remove any rounding or use the util.printf method to round the result to an given number of decimal places. One can also create their own rounding script.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
How do I use this script with the below?
I need for 2 decimals places to show with no rounding.
EX: the total is 73.449, right now it's rounding to 73.45. I want it just to show 73.44.
// Get first field value
var v1 = getField("Payroll6").value;
// Get second field value
var v2 = getField("Payroll7").value;
// Set this field value equal to the difference
event.value = (v1 * v2);