代码点读机 / Go / math.Pow

math.Pow Go · 包功能

返回 x 的 y 次幂。

怎么用

math.Pow(x, y)

小例子

package main
import (
    "fmt"
    "math"
)

func main() {
    fmt.Println(math.Pow(2, 3))
}

运行结果

输出 8

提醒:x 和 y 都必须是 float64

官方文档:https://pkg.go.dev/math#Pow

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Go全部词条