GoLang – Find not-a-number value – NaN() Function – Examples & Explanation

NaN() function is used to find the IEEE 754 “not-a-number” value in Go language. The standard math package of Go programming language has NaN() function.

Syntax of NaN() Function in Go Language

The syntax of NaN() function in Go Language is:

func NaN() float64

Note: float64 is a data type in Go language which has IEEE-754 64-bit floating-point numbers.


Parameters of NaN() Function in Go

The parameter is not required.


Error Handling

If you enter any value as a parameter, it will produce an error .


Return Value of NaN() Function in Go

NaN() function will return an IEEE 754 “not-a-number” value.


GoLang NaN() Function Example

package main

import "fmt"
import "math"

func main() {
	var x float64
	x = math.NaN()