On Sat, Mar 22, 2008 at 3:37 PM, Richard <[EMAIL PROTECTED]> wrote:
[snip=code!]
> When I have one item at 10.03, the result is : Total Vat = 1.97 - Total
> without vat = 10.03 Total with vat = 12.00
> but if I have two items at 10.03 the result is : Total vat = 3.93 -
> Total without vat = 20.06 Total with vat = 23.99
> but I need it to be : Total vat = 3.94 - Total without vat = 20.06 Total
> with vat = 24.00
Check your math, Richard. You're using sprintf() with the float
correctly, you're just missing how it's rounding.
(10.03 * 19.6) / 100 = 1.96588 (rounded to 1.97)
((10.03 * 19.6) / 100) * 2 = 3.93176 (rounded to 3.93)
If you want it to come out to an even number with the VAT added,
simply round the amount first, then multiply it.
--
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php