This may be irrelevant for the aqpplication being considered, but if things are being done on Linux there is the program 'bc', which does its arithmetic using an internal *decimal* representation, and to an arbitrary precision (truncating, rather than rounding, for the purpose of returning numbers to a given number of decimal disgits).
You set the precision (number of digits after the decimal point) by giving a value to the 'scale' variable. Therefore I would expect that (given the VAT specification to work to 4 d.p.) you could use 'bc' with scale=5 or scale=6, and then doing a bit of extra tweaking to evaluate the rounded value.
One more comment (on a point which does not seem to have been mentioned). "Rounding" is usually understood to mean "return the nearest "integer" at the right-hand end of the return range, so that (e.g.)
round(1.234, 1) -> 1.2. round(1.234, 2) -> 1.23 round(1.23456, 2) -> 1.23 round(1.23456, 3) -> 1.235
But what about
round(1.2345, 3)??
Is this 1.234 or 1.235? There are different conventions. A: Round "5" up: round(1.2345, 3) -> 1.235 round(1.2355, 3) -> 1.236
B: Round "5" down: round(1.2345, 3) -> 1.234 round(1.2355, 3) -> 1.235
C: Round "5" to the nearest *even* result: round(1.2345, 3) -> 1.234 round(1.2355, 3) -> 1.236
(You can never get an odd last digit with method C). This is the method of the IEC 60559 standard.
The VAT rules seem to say that *any* fraction (in the final result) may be rounded down, though there seem to be ifs & buts about it! This is rounding by truncation (as also done in 'bc').
Just a few thoughts ... Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 12-Oct-09 Time: 15:15:28 ------------------------------ XFMail ------------------------------