繁体   English   中英

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的 function,可用于将浮点数舍入到指定精度:

SQLite round() function 将浮点值 t 舍入到小数点右边的数位。 如果省略第二个参数(四舍五入的数字),则假定为 0。

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

SELECT round(799.9/150.0, 16)

这将输出数字5.332666666666667

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

SELECT round(799.9/150.0)

这将返回5.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM