complx.Rect() Golang中的函數返回具有極坐標r,θ的複數x。它以float值作為輸入並返回複數。此方法屬於複雜包。
用法:
func Rect(r, θ float64) complex128;
在此,r和θ是具有float64實部和虛部的複數。
返回值:它返回複數個極坐標r和θ。
範例1:本示例通過傳遞參數(5,45)來計算值。
// Golang program to illustrate
// the complx.Rect() Function
package main
// importing fmt and math/cmplx
import (
"fmt"
"math/cmplx"
)
// Calling Main method
func main () {
// using the function
fmt.Printf ("%.1f", cmplx.Rect (5, 45))
}
輸出:
(2.6+4.3i)
範例2:
// Golang program to illustrate
// the complx.Rect() Function
package main
// importing fmt, math and math/cmplx
import (
"fmt"
"math"
"math/cmplx"
)
// Calling Main method
func main() {
// using the function
fmt.Printf("%.1f,", cmplx.Rect(5, 4*math.Pi))
fmt.Printf("%.1f", cmplx.Rect(5, 90))
}
輸出:
(5.0-0.0i),(-2.2+4.5i)
相關用法
- 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()用法及代碼示例
注:本文由純淨天空篩選整理自PranchalKatiyar大神的英文原創作品 complx.Rect() Function in Golang With Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。