如何在sqlite中四舍五入到小数点后16位

How to round up to the 16th decimal place in sqlite

我想知道如何在 SQLite 中扩展到第 16 位小数,例如

SELECT 799.9/150.0 --Answer rounded up to the 16th decimal place.

SQLite 有一个名为 round 的函数,可用于将浮点数舍入到指定的精度:

SQLite round() function rounds a floating-point value t up to a number of digits to the right of the decimal point. If the 2nd argument (rounded digits) is omitted, it is assumed to be 0.

要将数字四舍五入到小数点后第 16 位,您必须将查询修改为如下所示:

SELECT round(799.9/150.0, 16)

这会输出数字 5.332666666666667

如果你根本不需要小数,可以省略第二个参数:

SELECT round(799.9/150.0)

这将 return 5.0