complx.IsNaN() Function in Golang With Examples
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:
// Golang program to illustrate the usage of // IsNaN() function // Including main package package main // Importing fmt and math/cmplx import ( "fmt" "math/cmplx" ) // Calling main func main() { // Returns output fmt.Println(cmplx.IsNaN(3 + 4i)) } |
Output:
false
Example 2:
// Golang program to illustrate the usage of // IsNaN() function // Including main package package main // Importing fmt and math/cmplx import ( "fmt" "math/cmplx" ) // Calling main func main() { // Returns output fmt.Println(cmplx.IsNaN(-0i / 8)) } |
Output:
false