round()

返回舍入为指定精度的数字。

语法

round(number [,precision])

详细了解语法约定

参数

客户 类型​​ 必需 说明
数字 long 或 real 要计算舍入的数字。
精度 int 要舍入到的位数。 默认值为 0。

返回

舍入为指定精度的数字。

Round 与 bin() 函数的不同之处在于,round() 函数将数字舍入为特定的位数,而 bin() 函数将值舍入为给定箱大小的整数倍。 例如,round(2.15, 1) 返回 2.2,而 bin(2.15, 1) 返回 2。

示例

round(2.98765, 3)   // 2.988
round(2.15, 1)      // 2.2
round(2.15)         // 2 // equivalent to round(2.15, 0)
round(-50.55, -2)   // -100
round(21.5, -1)     // 20