> For the complete documentation index, see [llms.txt](https://documentation.soulver.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.soulver.app/zh/yu-fa-can-kao/general/number-rounding.md).

# 四舍五入

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

```
# 四舍五入到特定的小数位数
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()  | 地板函数   | 将数字向下取整到最接近的整数 |
