# isnan()

Anonymous contributor
Anonymous contributor
Published Nov 15, 2022
Contribute to Docs

The `isnan()` function returns a number telling whether a given value is a `NaN` value.

## Syntax

``````isnan(x)
``````

The `x` parameter is a floating-point value that can be of type `float`, `double`, `long double`, or `int`. The return value is 1 if `x` is `NaN`. Otherwise, 0 is returned.

Note: Common cases of a `NaN` value include:

• Taking the square root of a negative value
• Dividing positive or negative zero by positive or negative zero (0/0)

## Example

In the example below, the `isnan()` function checks whether or not the value of `x` is `NaN`:

```#include <iostream>#include<math.h>using namespace std;
int main() {  float x = 0.0 / 0.0;  cout << "value of isnan(x) is: " << isnan(x) << "\n";  return 0;}
```

This produces the following output:

``````value of isnan(x) is: 1
``````

## Codebyte Example

In the example below, each possible data type is applied to the `isnan()` function. The application of the `int` type involves the `sqrt()` function:

`usVisit uscodeHide codeCodeOutputHide outputHide outputLoading...`