Skip to content

nan-comparison

Detect direct comparisons with NaN.

Updated View as Markdown

Default severity: error

IEEE floating-point NaN is unequal to every value, including itself, and all ordered comparisons with it are false. Use math.IsNaN when testing whether a value is NaN.

Bad

if value == math.NaN() { handle() }

Good

if math.IsNaN(value) { handle() }
Navigation

Type to search…

↑↓ navigate↵ selectEsc close