Welcome Guest, Not a member yet? Register   Sign In
how to store pricing (anyone have any helpers for price data?)
#9

[eluser]n0xie[/eluser]
[quote author="Aken" date="1258444330"]Actually I was rather unfamiliar with the float column type in databases. I assumed it was similar to a PHP float. [/quote]
As my PHP example illustrates, the PHP float is subject to the same errors in calculation. This is inherent to the float data type.

One would expect that floor((0.1+0.7)*10) would be 8, not 7. This could be a major issue if you run any form of E-Commerce.

Quote:I never did say that a float is the best resource to use, though. I said it works fine for me.
I wonder about that. Maybe you haven't noticed it because you always assumed that float calculations wouldn't influence the outcome.

Quote:And suggested that people always sanitize their numbers relating to money BEFORE entering them into a database, and not using it to round off numbers and such.
Sanitation doesn't help here. It is inherent to the way computers do floating point calculations. See my PHP example.


Messages In This Thread
how to store pricing (anyone have any helpers for price data?) - by El Forum - 11-17-2009, 03:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB