我有一个包含 Double(9,8) 列的表。当我尝试在该列中从 PHP 插入值 10 时,我最终得到 9.99999999。
我能理解舍入误差,但这首先是一个整数。任何帮助表示赞赏:)
最佳答案
Double(9,8)
表示:
- 9 总计
- 其中8位是小数
这是数字的格式:
0.00000000
因此,您可以通过输入10 得到最接近的值是9.9999999
MySQL permits a nonstandard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D). Here, “(M,D)”means than values can be stored with up to M digits in total, of which D digits may be after the decimal point. For example, a column defined as FLOAT(7,4) will look like -999.9999 when displayed. MySQL performs rounding when storing values, so if you insert 999.00009 into a FLOAT(7,4) column, the approximate result is 999.0001.
关于php - 在 MySQL Double(9,8) 列中插入值 10 并以 9.99999999 结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19266399/