在MySQL中存储0.00001 [英] Storing 0.00001 in MySQL
问题描述
我有一个赚取网站,我希望用户每次点击可赚取0.00001 (我知道它在1p以下).
I have an earn site and I would like the user to earn 0.00001 per click (I know it's under 1p).
我可以使用哪种类型的列?我已经尝试过int
和float
,但是都没有用.
What type of column could I use? I have tried int
and float
but neither works.
推荐答案
使用 DECIMAL
获取准确值.
Use DECIMAL
for exact values.
数字0.00001
有6位数字.小数点前1位和小数后5位.因此,它将表示为DECIMAL(6, 5)
(6位数字,其中5位在小数点后).如果想在小数点前加4位,在小数点后加5位,则可以使用DECIMAL(9, 5)
(总共9位,其中5位在小数点后).
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).
另请参阅:
- Precision Math
- Problems with Floating-Point Values
这篇关于在MySQL中存储0.00001的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!