Open In App

complx.NaN() Function in Golang With Examples

Last Updated : 28 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads