complx.NaN() Function in Golang With Examples

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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())
}

chevron_right


Output:

(NaN+NaNi)

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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()))
  
}

chevron_right


Output:

true
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.