complx.Inf() Function in Golang With Examples
Last Updated :
17 May, 2020
complx.Inf() Function in Golang is used to returns a complex infinity, complex(+Inf, +Inf). TO use this function one must need to import the “math/cmplx” package.
Syntax:
func Inf() complex128
Return Type: It returns a complex infinity.
Example 1:
package main
import (
"fmt"
"math/cmplx"
)
func main() {
fmt.Printf( "%f" , cmplx.Inf())
}
|
Output:
(+Inf+Infi)
Example 2: You can also generate a complex infinite number as shown below
package main
import (
"fmt"
"math"
)
func main() {
inf := math.Inf(1)
cmp := complex(inf, inf)
fmt.Printf( "%f" , cmp)
}
|
Output:
(+Inf+Infi)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...