go Exp()
Exp()方法语法
func Exp(x float64) float64
go源码对Exp()方法的介绍:
Exp returns e**x, the base-e exponential of x.
Special cases are:
Exp(+Inf) = +Inf
Exp(NaN) = NaN
Very large values overflow to 0 or +Inf. Very small values underflow to 1.
golang标准库模块math的Exp()方法,是自然常数e的x次方,x为Exp()接收到的float64类型参数。如果参数x的绝对值很大,返回值可能会溢出为0或者+Inf,如果x绝对值很小,则可能会下溢为1。除此之外,Exp(+Inf) = +Inf;Exp(NaN) = NaN。
math.Exp()方法实例代码
func main() {
exp_v := math.Exp(1)
fmt.Println(exp_v)
fmt.Println(math.E)
}
运行go文件,得到输出:
2.718281828459045
2.718281828459045