The point about storing dollars and counting cents is that no fractions are stored exactly. They are in floating point, and this can have surprising consequences.]]>

Yeah! I got it. The problem was it was taking the full value of the AmtPay1new field ( $916.6666666666665) which does, in fact =$11,000.00 so I needed to round that figure in a new field called AMT_PAY1new2points. Here is the script:

var nValue = this.getField("AMT_PAY1new").value;

var nPrecision = +2;

nPrecsision = -nPrecision;

var nAdjustment = Math.pow(10, nPrecision);

nValue = nValue * nAdjustment;

nValue = Math.ceil(nValue);

event.value = nValue / nAdjustment;

My total of payment (and finance charge accordingly) reads $11,000.04

My display actually needs to show the cents too (it's for the disclosure of the total of payments on a loan). I am not putting in any rounding options within the .pdf. Is that something that java does all on it's own? If so, how do I get it to knock it off?

The fields that have a monetary value are formatted as Number, 2 Decimal Places and a separator style of 1,234.56.

The Number of payments field is formatted as Number, 0 Decimal Places and a separator style of 1234.56.

I'd break it down into cents, like you suggested, but I don't see how it will hold a value if the java continues to round.

]]>
Thanks again for any info.

-Rae

If you're working with money exact accuracy is important, so it's vital to understand exactly how JavaScript stores numbers. Auditors will demand as much! A common approach is to work in cents/pennies, and round up only for display.]]>

I've tried this with java too but here is the simple calc. example I am having problems with:

(Value is the product (x) of the following fields:

AmtPay1new, Number of Payments

AmtPay1new value=$916.67

Number of Payments=12

I keep getting $11,000.00 instead of $11,000.04

Any ideas are greatly appreciated. Is this case 4 cents matter (believe it or not).

Thank you,

Rae