complx.IsNaN() Function in Golang With Examples
Last Updated :
15 Apr, 2020
In Go language, cmplx packages supply basic constants as well as mathematical functions for the complex numbers. The IsNaN() function in Go language is used to check if either the stated real(x) or imag(x) is NaN or not and is neither an infinity. Moreover, this function is defined under the cmplx package. Here, you need to import “math/cmplx” package in order to use these functions.
Syntax:
func IsNaN(x complex128) bool
Here, x is the set of all complex numbers with float64 real as well as imaginary parts.
Return value: It returns true if x is NaN else it returns false.
Example 1:
package main
import (
"fmt"
"math/cmplx"
)
func main() {
fmt.Println(cmplx.IsNaN(3 + 4i))
}
|
Output:
false
Example 2:
package main
import (
"fmt"
"math/cmplx"
)
func main() {
fmt.Println(cmplx.IsNaN(-0i / 8))
}
|
Output:
false
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...