Today I Learned

hashrocket A Hashrocket project

In Go, NaN does not equal NaN

It's false, it returns false.

fmt.Println(math.NaN == math.NaN)

Don't fret though, there is a function that can tell you whether or not a value is NaN.


The above returns true and all is well with the world. Don't use math.NaN as a sentinel value, it does not work, use the math.IsNaN function.

See More #go TILs