math.round() 函数
math.round()
返回最接近的整数,将一半舍入远离零。
函数类型签名
(x: float) => float
有关更多信息,请参阅函数类型签名。
参数
x
(必需)要操作的值。
示例
将值四舍五入到最接近的整数
import "math"
math.round(x: 2.12)// 2.0
在 map 中使用 math.round
import "math"
import "sampledata"
sampledata.float()
|> map(fn: (r) => ({r with _value: math.round(x: r._value)}))
此页面是否对您有帮助?
感谢您的反馈!