# isNaN() Function & Examples

Use the isNaN() utils function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## isNaN

#### isNaN(x)

Try it yourself:

```calculio
isNaN(2)
isNaN(0 / 0)
isNaN(NaN)
isNaN(Infinity)
```

---

## isNaN(): detect invalid numeric results

**isNaN(x)** tests whether x is the special “not a number” value. NaN often results from undefined arithmetic, failed conversion, or invalid numerical input.

## Use it as a guard

Check a result before continuing a calculation or rendering a chart. NaN tends to propagate through arithmetic, so early detection is clearer than debugging a later [sum()](https://calcul.io/function/sum/index.md) or [mean()](https://calcul.io/function/mean/index.md).

## Related tests

[isFinite()](https://calcul.io/function/isFinite/index.md) also rejects infinities. [isNumeric()](https://calcul.io/function/isNumeric/index.md) checks whether a value is numeric in the first place, and [isInteger()](https://calcul.io/function/isInteger/index.md) narrows the accepted domain further. Use [isZero()](https://calcul.io/function/isZero/index.md) before division where zero is the issue.

## Do not compare directly

NaN is not reliably identified with ordinary equality. Use this predicate rather than comparing a value to NaN.

[All functions](https://calcul.io/functions/index.md)
