I have an earn site and I would like the user to earn 0.00001 per click (开发者_如何学PythonI know it's under 1p).
What type of column could I use? I have tried int
and float
but neither works.
Use DECIMAL
for exact values.
The number 0.00001
has 6 digits. 1 before and 5 after the decimal point. Therefore, it would be represented as DECIMAL(6, 5)
(6 digits out of which 5 are after the decimal point). If you would like to have, say, 4 digits before and 5 digits after the decimal point, you'd use DECIMAL(9, 5)
(9 in total, out of which 5 are after the decimal point).
Also see:
- Precision Math
- Problems with Floating-Point Values
You use INT and divide by 100000 when you display the value.
You'll probably want a DECIMAL data type.
Try using the decimal column type with a value of (9,5), where 9 is the total number of digits (before and after the decimal place) and 5 is how many digits come after the decimal place. For more information on this column type, check out the MySql documentation page:
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
精彩评论