Magento-RestApi
Magento-RestApi copied to clipboard
Double-Precision Floating Point Currency?
For real? (narf!) Given the very many well-known and widely reported, monumental issues with floating-point math and precision vis a vis money calculations, why aren't the currency-related fields in this project declared as type Decimal?
Using Double (or Single) instead seems to just be BEGGING for inaccurate calculations to crop up for, as far as I can tell, no benefit whatsoever. What's the thinking behind this?
Sure enough, I'm getting stupid floating point value drift and crazy fractional cents values despite the database table containing perfectly normal currency values. I'm going to apply formatting to hopefully constrain the horror show, but I cannot help but expect that I'm going to have erroneous calculations eventually.
Looking at this StackOverflow thread, the commenters state repeatedly that you should never use floating point types for currency... http://stackoverflow.com/questions/890100/how-do-i-format-a-double-to-currency-rounded-to-the-nearst-dollar