Open In App

complx.Inf() Function in Golang With Examples

Last Updated : 17 May, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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: C
// 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())
}
Output:
(+Inf+Infi)
Example 2: You can also generate a complex infinite number as shown below C
// 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)
}
Output:
(+Inf+Infi)

Next Article
Article Tags :

Similar Reads