Page 1 of 1

Currencies not accepting my input correctly

Posted: Sat Nov 27, 2021 1:46 pm
by Moxamint
Hi All,

My bank provided me with a chart of currency exchange rates. I don't use the source that Phoenix Cart provides. Each currency value in my chart has only four decimal places instead of 8. For example, the exchange rate USD:EUR = 1:0.8748. My question is: when I entered 0.8748000 as the EUR value, why does it always turn out something like 0.87480003, not exactly 0.87480000?

Many thanks in advance for your help.

Eddy

Re: Currencies not accepting my input correctly

Posted: Sat Nov 27, 2021 2:53 pm
by ecartz
It's because the floating point values traditionally used don't handle precision well. You'd probably be able to see the same problem with eight digits. It's just more obvious with replacing the trailing zeroes and with you entering the values manually.

This shouldn't actually be a problem generally, because the rounding should make the difference disappear. Because I don't know of a currency that actually has eight digits of precision. So you'd have to be selling at least a few thousand to notice even with four digits of precision. And more the less precision your currency has.