
1. Re: Calculations with Rounded Numbers
George_Johnson May 29, 2012 12:44 PM (in response to MJBateman1)You'll have to use JavaScript. The code for the custom calculation script for your example would be:
// Cust calculation script
(function () {
// Get the field values, rounded to nearest integer
var v1 = Math.round(+getField("fieldA").value);
var v2 = Math.round(+getField("fieldB").value);
// Set this field value to the difference
event.value = v1  v2;
})();
Replace "fieldA" and "fieldB" in the code above with the actual field names.

2. Re: Calculations with Rounded Numbers
gkaiseril May 29, 2012 12:52 PM (in response to MJBateman1)Well this is the way JavaScirpt works and for many calculations the unrounded nubmers are needed for the calculaitons.
You need to set the value of the calculated field to the rounded value.
I would use a custom calculation script and you can use JavaScript's "Math.round" method or Acrobat's "util.printf" method.
event.value = Math.round(event.value);
event.value  util.printf("%,1 .0f", event.value);

3. Re: Calculations with Rounded Numbers
MJBateman1 May 29, 2012 1:34 PM (in response to George_Johnson)George I must be missing something. I added the math.round functions as shown in your example but now it doesn't calculate at all. Can you look at the coding shown below and let me know where I went wrong? Thanks.
Updated Coding:
(function(){
var totalMiles = math.round(+this.getField("Total Miles DrivenRow1").value);
var homeMiles = math.round(+this.getField("Home Base MilesRow1").value);
var diff = totalMiles  homeMiles;
if (diff<0) diff = 0;
event.value = diff;})();
Original Coding:
var totalMiles = +this.getField("Total Miles DrivenRow1").value;
var homeMiles = +this.getField("Home Base MilesRow1").value;
var diff = totalMiles  homeMiles;
if (diff<0) diff = 0;
event.value = diff;

4. Re: Calculations with Rounded Numbers
MJBateman1 May 29, 2012 1:35 PM (in response to gkaiseril)GKaiseril are you saying you think I can just add the math.round function to the "event value" at the end of the coding?

5. Re: Calculations with Rounded Numbers
George_Johnson May 29, 2012 1:37 PM (in response to MJBateman1)It's not math.round, it's Math.round.

6. Re: Calculations with Rounded Numbers
gkaiseril May 29, 2012 2:17 PM (in response to MJBateman1)Yes you can, and I would do it for each calculated field where you want the rounded value of the calculation used.
If you use the Math object's round method you use:
Math.round(FloatingPointValue)
"Math" has to have the first letter capitalized.