[ic] Currency Conversion Floating Point Errors?

Paul Jordan paul at gishnetwork.com
Thu Feb 26 00:57:25 UTC 2009

From: "Jake DiBella" <jake at geton.ca>
Sent: Wednesday, February 25, 2009 1:39 PM
To: <interchange-users at icdevgroup.org>
Subject: [ic] Currency Conversion Floating Point Errors?

> Hi All,
> Recently, I've been getting some strange rounding errors when applying 
> currency conversion to products. I have a product priced at $300.00 USD, 
> and I'm applying a 5% tax to it.  When done using USD, the amount 
> correctly gets calculated as $15.00.  Upon entering a Canadian address, 
> and after changing the State/Province dropdown accordingly, the new price 
> is incorrect.  The prices are as follows:
> --------------
> Price: $300.00
> GST (5%):   $15.00
> ----------------
> Price: $333.33
> GST (5%):   $18.52
> http://www.paste.me.uk/1263.html - Shopping Cart code
> http://www.paste.me.uk/1264.html - PriceDivide settings
> http://www.paste.me.uk/1265.html - State table excerpt
> I think the issue is caused by a floating point rounding error occurring 
> in the [currency] tag, but I don't know how to go about fixing this.  Can 
> anyone help?

Hi Jake

I have not seen you post yet so I'll just archive the answer for us. On IRC 
we found it was his use of the [currency] tag on line #6 here:

http://www.paste.me.uk/1263.html - Shopping Cart code

Basically it was converting the levy amount twice.

Paul Jordan
  Gish Network
  For Print, Web, and Life

More information about the interchange-users mailing list