go Hypot()

Hypot()方法语法

func Hypot(p, q float64) float64

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

Hypot returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow.

Special cases are:

Hypot(±Inf, q) = +Inf
Hypot(p, ±Inf) = +Inf
Hypot(NaN, q) = NaN
Hypot(p, NaN) = NaN

golang标准库math.Hypot()方法,可求取参数p²+q²的和的二次方根。除此之外,Hypot(±Inf, q) = +Inf;Hypot(p, ±Inf) = +Inf;Hypot(NaN, q) = NaN;Hypot(p, NaN) = NaN。


math.Hypot()方法实例代码

func main() {
	hypot_num := math.Hypot(1.5, 2)
	fmt.Println(hypot_num)
}

运行go文件,得到输出:

2.5

全栈后端 / go语法 :













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