Mysql: money and floats
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 remo开发者_如何学运维ved)
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.
Try DECIMAL. See http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html
精彩评论