go Frexp()
Frexp()方法语法
func Frexp(f float64) (frac float64, exp int)
go源码对Frexp()方法的介绍:
Frexp breaks f into a normalized fraction and an integral power of two. It returns frac and exp satisfying f == frac × 2**exp, with the absolute value of frac in the interval [½, 1).
Special cases are:
Frexp(±0) = ±0, 0
Frexp(±Inf) = ±Inf, 0
Frexp(NaN) = NaN, 0
golang标准库模块math.Frexp()方法,可返回两个返回值,分别为归一化分数frac和2的整型指数exp,且二者满足f == frac x 2**exp和frac的绝对值在[0.5, 1)之间。除此之外,Frexp(±0) = ±0, 0;Frexp(±Inf) = ±Inf, 0;Frexp(NaN) = NaN, 0。
math.Frexp()方法实例代码
func main() {
frac, exp := math.Frexp(3)
fmt.Println(frac)
fmt.Println(exp)
}
运行go文件,得到输出:
0.75
2