函数 round() 可以将数值四舍五入到指定精度,即返回距离该数值最近的某一精度的数字,如果同时存在两个最近的数字,则返回绝对值较大的一个。
Arguments:
- 数值 <number>
- 精度 <integer>,-1 精确至十位,0 精确至个位,1 精确至一位小数,以此类推,不填则默认为 0
Returns:
- 结果 <number>
一般用法
示例:异源别名直接计算
uncollect [-3.75, 7.55] as a
uncollect [0, 1] as b
return table(a, b, round(a, b))
| a | b | round(a, b) |
|-------|---|-------------|
| -3.75 | 0 | -4 |
| 7.55 | 1 | 7.6 |
示例:异源别名笛卡尔乘积后计算
uncollect [-3.75, 7.55] as a
uncollect [0, 1] as b
with round(a, b) as c
return table(a, b, c)
| a | b | c |
|-------|---|------|
| -3.75 | 0 | -4 |
| -3.75 | 1 | -3.8 |
| 7.55 | 0 | 8 |
| 7.55 | 1 | 7.6 |