What float do I need to store such sums like these: $1,200,000, $1,000, and $14.56 ? ($ dosn't count; it will be removed)
+4
A:
Don't. Store as an int and multiply/divide by 100. e.g. Store 14.56 as 1456, but /100 when displaying. Floating point for storing currency is just asking for rounding problems.
Mike
2010-03-04 19:42:21
So do you think i should store $1,000 as 1000? and then devide it by 100? = 10?
AleGore
2010-03-04 19:47:42
No, always assume 2 places for cents, i.e. 1000 = 100000 in storage. Of course, if you're dealing with more than just 2 decimal places for cents, i.e. handling fractions of cents (financial industry perhaps) then this technique won't work for you.
Mike
2010-03-04 19:57:43
A:
Try DECIMAL. See http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html
Nathan
2010-03-04 19:59:35