Gol語言中的complx.Pow()函數用於查找x ** y,即y的base-x index 。為此函數,需要導入“math/cmplx”程序包。
用法:
func Pow(x, y complex128) complex128
- Pow(0,±0)返回1 + 0i
- 如果imag(c)為零,則real(c)<0的Pow(0,c)返回Inf + 0i,否則為Inf + Inf i
參數:使用的參數是兩個複數,其中complex128是具有float64實部和虛部的所有複數的集合。此函數的返回類型也是一個複數。
範例1:
package main
import (
"fmt"
"math/cmplx"
)
func main() {
var a complex128
var b complex128
a= complex(2,5)
b= complex(3,7)
fmt.Println(cmplx.Pow(a,b))
}
輸出:
(-0.03528847161704272+0.0129436389603905i)
範例2:
// Golang program to illustrate
// the complx.Pow() Function
package main
import (
"fmt"
"math/cmplx"
)
func main() {
var a complex128
var b complex128
a= complex(1,2)
b= complex(1,0)
// using the function
fmt.Println(cmplx.Pow(a,b))
}
輸出:
(1.0000000000000002+2i)
相關用法
- Golang math.Lgamma()用法及代碼示例
- Golang math.Float64bits()用法及代碼示例
- Golang atomic.AddInt64()用法及代碼示例
- Golang atomic.StoreInt64()用法及代碼示例
- Golang reflect.FieldByIndex()用法及代碼示例
- Golang string.Contains用法及代碼示例
- Golang bits.Sub()用法及代碼示例
- Golang io.PipeWriter.CloseWithError()用法及代碼示例
- Golang time.Round()用法及代碼示例
- Golang reflect.AppendSlice()用法及代碼示例
- Golang reflect.ChanOf()用法及代碼示例
- Golang flag.Bool()用法及代碼示例
- Golang time.Sleep()用法及代碼示例
- Golang time.Time.Year()用法及代碼示例
- Golang reflect.DeepEqual()用法及代碼示例
- Golang reflect.Indirect()用法及代碼示例
- Golang reflect.CanAddr()用法及代碼示例
- Golang reflect.CanInterface()用法及代碼示例
- Golang reflect.CanSet()用法及代碼示例
- Golang reflect.Cap()用法及代碼示例
注:本文由純淨天空篩選整理自prakhar7大神的英文原創作品 complx.Pow() Function in Golang With Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。