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