math.frexp() 函数
math.frexp() 将 f 分解为一个标准化的分数和一个二的整数部分。
它返回 frac 和 exp,满足 f == frac x 2**exp,其中 frac 的绝对值在区间 [1/2, 1) 内。
函数类型签名
(f: float) => {frac: float, exp: int}
有关更多信息,请参见 Function type signatures。
参数
f
(必填) 要操作的值。
示例
返回一个值的标准化分数和积分
import "math"
math.frexp(f: 22.0)// {exp: 5, frac: 0.6875}
在map中使用math.frexp
import "sampledata"
import "math"
sampledata.float()
|> map(
fn: (r) => {
result = math.frexp(f: r._value)
return {r with exp: result.exp, frac: result.frac}
},
)