For the complete documentation index, see llms.txt. This page is also available as Markdown.

四舍五入

指定答案需要四舍五入的小数位数。这将覆盖该行的默认精度设置。

# 四舍五入到特定的小数位数
1/3 to 2 dp     | 0.33
π to 5 digits   | 3.14159

# 四舍五入向上和向下
5.5 四舍五入                     | 6
5.5 向下取整                | 5
5.5 向上取整                  | 6

# 四舍五入到最近的 x
37 到最近的 10                | 40
$490 舍入到最近的 100 | $500
2,100 到最近的 1000   | 2,000

# 四舍五入到最近的 x 的向上和向下
21 向上取整到最近的 5      | 25
17 向下取整到最近的 3    | 15

或者使用以下函数之一:

Function
Name
Behaviour

round()

整数四舍五入

将数字四舍五入到最接近的整数

ceil()

天花板函数

将数字向上取整到最接近的整数

floor()

地板函数

将数字向下取整到最接近的整数

按分数取整

指定分母,将数值四舍五入到最接近的分数:

0.534 to nearest 16th9/16

这适用于木工测量及其他使用分数增量的任务。

最后更新于