Gol語言中的complx.Inf()函數用於返回複數無窮大,complex(+ Inf,+ Inf)。要使用此函數,必須導入“math/cmplx”軟件包。
用法:
func Inf() complex128
返回類型:它返回一個複雜的無窮大。
範例1:
// Golang program to illustrate
// the complx.Inf() Function
package main
// importing fmt and math/cmplx
import (
"fmt"
"math/cmplx"
)
// calling main method
func main() {
// returns the complex Infinite number
fmt.Printf("%f", cmplx.Inf())
}
輸出:
(+Inf+Infi)
範例2:您還可以生成一個複數無窮數,如下所示
// Golang program to generate
// complex infinite number
package main
// importing fmt and math
import (
"fmt"
"math"
)
// calling main method
func main() {
// returns a infinite value
inf:= math.Inf(1)
// make a complex infinite number
cmp:= complex(inf, inf)
// print the number
fmt.Printf("%f", cmp)
}
輸出:
(+Inf+Infi)
相關用法
- 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.Inf() Function in Golang With Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。