---
title: "nan-comparison"
description: "Detect direct comparisons with NaN."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# nan-comparison

**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

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

## Good

```go
if math.IsNaN(value) { handle() }
```

Source: https://strider.gempir.com/analyzers/nan-comparison/index.mdx
