I keep getting rounding errors when calculating amounts involving unit prices and quantities. All unit prices in their tables are formatted as Currency. These amounts below are in currency apart from the end ones, which are the true amounts.
[pre]
Item Quantity Unit Price Discount at 5% Value Unformatted Value
Product 1 1 92.11 4.61 (5%) 87.50 87.50
Product 2 2 93.41 4.67 (5%) 177.48 177.48
Product 3 1 92.11 0.00 (0%) 92.11 92.11
Total 357.09 357.09
Credit item
Product 4 0.25 92.11 23.03 23.0275
Subtotal 334.06 334.0625
VAT at 20% 66.81 46.8125
Displayed Grand Total 400.88 400.875
Would expect 334.06 + 66.81 to be 400.87
[/pre]
I know rounding is well discussed but I don't seem able to get sensible results. Does a currency amount have 2 or 4 decimal places behind the scene, and how can I force the 'expected' answer of 400.87?