Here, We will learn how to check if number is an IEEE 754 not-a-number value in go. We can get it by using IsNaN() function in math package in go golang.
Function prototype:
func IsNaN(num float64) (is bool)
Return value:
IsNaN() function in math package checks
whether num is an IEEE 754 “not-a-number”
value.
Example with code:
package main
import (
"fmt"
"math"
)
func main() {
no := math.IsNaN(1)
fmt.Println(no)
no = math.IsNaN(2.7)
fmt.Println(no)
no = math.IsNaN(0.2)
fmt.Println(no)
no = math.IsNaN(-2)
fmt.Println(no)
no = math.IsNaN(-2.7)
fmt.Println(no)
}
Output:
false
false
false
false
false
To learn more about golang, Please refer given below link:
https://techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/