go Expm1()

Expm1()方法语法

func Expm1(x float64) float64

go源码对Expm1()方法的介绍:

Expm1 returns e**x - 1, the base-e exponential of x minus 1. It is more accurate than Exp(x) - 1 when x is near zero.

Special cases are:

Expm1(+Inf) = +Inf
Expm1(-Inf) = -1
Expm1(NaN) = NaN
Very large values overflow to -1 or +Inf.

golang标准库模块math.Expm1()方法,返回值为e的x次方,并减去1,即e**x - 1。当参数x接近于0时,比Exp(x)-1更精确。除此之外,Expm1(+Inf) = +Inf;Expm1(-Inf) = -1;Expm1(NaN) = NaN。


math.Expm1()方法实例代码

func main() {
	expm1_v := math.Expm1(1)
	fmt.Println(expm1_v)
	fmt.Println(math.E - 1)
}

运行go文件,得到输出:

1.718281828459045
1.7182818284590453

全栈后端 / go语法 :













Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.