Open In App

complx.NaN() Function in Golang With Examples

Last Updated : 28 Apr, 2020
Comments
Improve
Suggest changes
Like Article
Like
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: C
// 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: C
// 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

Next Article
Article Tags :

Similar Reads