Errors Calculating Vat

joanwelms

New member
Hi Guys,

Why do I get the wrong results with the code below.

iAmount = 16.84
iVatAmt = ((iAmount * 17.5) \ 100) (Returns 2.00 instead of 2.947)

iTotalAmt = iAmount + iVatAmt (Should = 19.79 but comes back with 18.84)

I know that the "\" means interger division but if I use "/" I keep getting errors reported from PayPal that the Amount being passed to it is formatted incorrectly.

How do I calculate and add the vat element to the iAmount keeping the correct decimal format.

Thanks for your help.
 
Top