complx.IsInf() Function in Golang With Examples
Last Updated :
28 Apr, 2020
complx.IsInf() Function in Golang reports whether either real(x) or imag(x) is an infinity. The returned value is boolean.
Syntax:
func IsInf(x complex128) bool
Here, x is the set of all complex numbers with float64 real as well as imaginary parts.
Return Value: This returns a boolean value, either true or false.
Example 1: This example checks whether 1+5i is infinity or not.
package main
import (
"fmt"
"math/cmplx"
)
func main() {
infy := complex(1, 5)
fmt.Printf( "%t" , cmplx.IsInf(infy))
}
|
Output:
false
Example 2: This example verifies that the var infy is infinite or not.
package main
import (
"fmt"
"math"
"math/cmplx"
)
func main() {
inf := math.Inf(1)
infy := complex(inf, inf)
fmt.Printf( "%t" , cmplx.IsInf(infy))
}
|
Output:
true
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...