complx.NaN() function in Golang is used to returns a complex “not-a-number” value.
Syntax:
func NaN() complex128
It returns the complex NaN value. Let us discuss this concept with the help of given examples:
Example 1:
// Golang program to illustrate // the complx.NaN() Function package main import ( "fmt"
"math/cmplx"
) // Main function func main() { // Using the function
fmt.Printf( "%.1f" , cmplx.NaN())
} |
Output:
(NaN+NaNi)
Example 2:
// Golang program to illustrate // the complx.NaN() Function package main import ( "fmt"
"math/cmplx"
) // Main function func main() { // checking if the generated value is Not-a-number or not?
fmt.Printf( "%t" , cmplx.IsNaN(cmplx.NaN()))
} |
Output:
true
Article Tags :