2 ms·
Is dollars not as floats just a MySQL issue? I am not sure why you wouldn’t want to do this.
by chrisgd 8y ago
Is dollars not as floats just a MySQL issue? I am not sure why you wouldn’t want to do this.
- Tostino 8y agoNo, that is not just MySQL. Just do a little googling and you'll run across enough information on why it's bad practice in any language or database. You need to avoid converting dollar values to a floating point at every place in your stack otherwise you will introduce floating-point rounding errors. It's not just the data type that it's stored in, if you convert it to that at any point, you lose the exact precision and introduce those errors. It can add up to some serious differences over a lot of values. I did some analysis on my database to see if I had stored any of those numbers is floating points, what would the amount difference be in total, and what would be the absolute difference for any single account. it was awhile ago, but I believe that the absolute difference per client was around $20 or $30, but the absolute difference per account within that client was as high as $100. Obviously that's pretty damn unacceptable.